..oO(Sanders Kaufman)
>Michael Fesser wrote:
>
>> But there's a similar thing that can be
>> really ful - variable class names, i.e. the class name is stored in
>> a variable:
>>
>> $foo = 'TMyClass';
>> $bar = new $foo(); // creates an instance of the class TMyClass
>
>Now I'm confused again.
>Maybe I'm applying Java logic here or something.
>Why doesn't that just create a new string containing, 'TMyClass'?
Because PHP is not Java.
In this case the name of the class is taken from the variable (notice
the parentheses after the variable name). The same can also be done with
functions, which is a common way to implement callback functions in PHP.
Micha