mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00
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:
parent
e426461d70
commit
0e89f54262
1 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue