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";

$model::model()->findAll();



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:

http://www.yiiframework.com/doc/api/1.1/CActiveDataProvider

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';

$model::staticFunction();

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.

http://www.yiiframework.com/doc/api/1.1/CActiveRecord#model-detail

okay… I get it… thanks Andy…