runeveryday Posted August 25, 2009 Share Posted August 25, 2009 <?php $object = new User; print_r ($object); class User { public $name, $password; function save_user() { echo "Save User code goes here"; } } ?> i am a beginner of php,i can't understand the above code's result.who can explain it for me? the more details of it .the better. Well in the code, the properties have never been set.in class User ,there is no return value? but when print_r($object) the result is "User Object ( [name] => [password] => ) "? how this come from? what the relationship between object and class. any help would be appreciated! Link to comment https://forums.phpfreaks.com/topic/171756-the-output-of-the-object/ Share on other sites More sharing options...
trq Posted August 25, 2009 Share Posted August 25, 2009 the properties have never been set. No, and thats exactly what print_r($object) shows. Empty properties. what the relationship between object and class A class is like a template for building an Object. ps: If your going to post code, at least format it like your trying to get help. Anyone who writes code in that format deserves for it to be misunderstood. Link to comment https://forums.phpfreaks.com/topic/171756-the-output-of-the-object/#findComment-905659 Share on other sites More sharing options...
runeveryday Posted August 25, 2009 Author Share Posted August 25, 2009 thank you! could you tell me the execution flow of the above code?is it in sequence? Link to comment https://forums.phpfreaks.com/topic/171756-the-output-of-the-object/#findComment-905663 Share on other sites More sharing options...
trq Posted August 25, 2009 Share Posted August 25, 2009 Code is executed top - down & left - right just like English is read. Link to comment https://forums.phpfreaks.com/topic/171756-the-output-of-the-object/#findComment-905667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.