Jump to content

the output of the object


runeveryday

Recommended Posts

<?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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.