note 121174 deleted from language.variables.variable by cmb
| From: | cmb@php.net | Date: | Sun, 12 Jan 2020 08:23:09 +0000 |
| Subject: | note 121174 deleted from language.variables.variable by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213854@lists.php.net to get a copy of this message | ||
Note Submitter: duartejuca at gmail dot com
----
// Acessing from class
//Lets create the class
class fooClass {
//Here I have one variable private
private $usr = 'littleJohn';
// here I have one variable public
public $psw = 'blablabla1982';
function fooFunction()
{
return $this->usr; // here I can read the private variable
// $this because I reading this object
// usr without '$' because is one component from this object
}
}
// Here I put the new class object inside of one container
$conn = new fooClass;
// now I read the function
echo $conn->functionFoo();
// now I read the value of variable inside of component in class
echo $conn->passw; // look without '$'
// if I try to read the private value like I do with public, I got one error
echo $conn->usr; // look without '$'