Search This Blog

Thursday, June 24, 2010

implicit class variable declaration in php?

Programmer Question

Hi,



I've been looking at some code and am having a hard time working out variable declaration in php classes. Specifically it appears that the code i'm looking at doesn't declare the class variables before it uses them. Now this may be expected but I can't find any info that states that it is possible. So would you expect this:



class Example
{

public function __construct()
{
$this->data = array();
$this->var = 'something';

}

}


to work? and does this create these variables on the class instance to be used hereafter?



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails