Added the following lines:

Both in and outside of the object you do not need a $ when accessing an
object's properties.

Also a code snippet to reference the previous statement.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@41072 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Chris Newbill 2001-02-09 19:41:08 +00:00
parent e426461d70
commit 0e89f54262

View file

@ -99,8 +99,24 @@ $ncart->add_item ("10", 1); // (inherited functionality from cart)
<para>
Within functions of a class the variable $this means this
object. You have to use $this->something to access any variable or
function named something within your current object.
function named something within your current object. Both in and
outside of the object you do not need a $ when accessing an object's
properties.
</para>
<informalexample>
<programlisting role="php">
$ncart->owner = "chris"; // no $
$ncart->$owner = "chris";
// this is invalid because $ncart->$owner = $ncart->""
$myvar = 'owner';
$ncart->$myvar = "chris";
// this is valid because $ncart->$myvar = $ncart->owner
</programlisting>
</informalexample>
<para>
Constructors are functions in a class that are automatically
called when you create a new instance of a class. A function