Class::Variable php Parse error: T_PAAMAYIM_NEKUDOTAYIM

I’ve encountered a problem regarding using accessing class using variable…

Says I have a model class name Post. And supposed I want to use like this:

$model = "Post";


In PHP 5.3 I’ve got no problem, because it run perfectly. After uploading to my hosting it then throw error which state something like parse error T_PAAMAYIM_NEKUDOTAYIM…Later I google a little and found out that PHP version under 5.3 doesn’t support this kind of code yet. So what should I do, if I want to access class using variable?

This could help you:

Oh yeah… it is working…

Thanks a lot Antonio :)

But what if I want to call certain method from the model class? Is there any function that Yii can provide?

like this?

$model = 'Post';


Make this function non-static and do the following:

$model = CActiveRecord::model($model)->myFunction();

Functions like findAll() should be static too, but they are not for a similar reason.

okay… I get it… thanks Andy…