Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   PHP function (http://www.go4expert.com/forums/php-function-t8677/)

hanliong 6Feb2008 09:44

PHP function
I have read at many article and PHP.net itself.
I'm very newbie with PHP. But i always see that people use php script like this:

I don't know, why use "this->". What is it use for? Can you help me with simple word to explain about this?

and many script use that arrow. Like this sample:
Code: PHP

$mail->AddReplyTo($email_reply_to_address, $email_reply_to_name);

why use ->? Can't it just mail($email_reply_to_address, $email_reply_to_name);?


pradeep 6Feb2008 09:53

Re: PHP function
I guess you are not aquainted with OOP (Object Oriented Programming - http://www.go4expert.com/showthread.php?t=436), this always refers to the “owner” of the function we're executing, or rather, to the object that a function is a method of.

In you example, $mail contains the instance of some Class/Object, and mail is a method of the Class/Object, to call the method we use the arrow (->) operator.

All times are GMT +5.5. The time now is 19:52.