Grid view column function($data) throws a syntax error on a different server [Solved]

Hi, I’ve searched the wiki and forums but haven’t found a solution so I’ve decided to start a new thread.

I’m developing an application on a Mac (with XAMPP) without any problems, but the error occurs once the application is deployed on a Linux production server (hosted at Hostgator.com). I’m using Yii 1.1.10.




Parse error: syntax error, unexpected T_FUNCTION in /home/username/public_html/appname/protected/views/word/index.php on line 28



Here’s the bit of grid view code that gives me the syntax error:




...

'columns'=>array(

    array(

        'name'=>'chinese',

        'value'=>function($data) {

            if ($data->dateCreated > date('Y-m-d H:i:s', strtotime('today'))) { // this is line 28

                echo '<a class="tooltips" rel="tooltip" data-original-title="Added today"><span class="label label-info">Today</span></a> ';

            }

            ...



Any help would be greatly appreciated!

I am guessing that the php version in your mac is different than the one on your linux server

make sure the PHP Version is 5.3.x

Hi what’s the PHP version on your host?

Thank you everyone for the quick responses! Switching from PHP 5.2.17 to 5.3.10 solved the problem.