Friday 2 September 2011

Gautam java script and PHP help: magic methods in PHP : __tostring

Do you know, PHP5 have some magic methods.
__tostring() is one of the magic method.
In any class , use this method for any purpose then create an instance of the class ,after that when you will use print function or echo to print the object of the class then print function automatically call __tosting method.

Example :-



Here echo $obj; will call __tostring() method and in output 'This is Gautam mukherjee' will print.

No comments:

Post a Comment