Correct way to define class variables
Posted: Wed Apr 25, 2007 12:00 am
I am just starting to use classes with PHP 4.3.10. When I have error reporting on I get PHP notices for all class variable access.
For example, with this code:
I get a notice for the access of the clienId member in the constructor:
For example, with this code:
Code: Select all
class Client
{
var $clientId = -1;
function Client($aClientId=-1)
{
$this->$clientId = $aClientId;
}
...What am I doing wrong? The class seems to work fine in spite of this.Notice: Undefined variable: clientId in /var/www/ozfl/common/classes/Client.php on line 12