GilZ Posted April 13, 2013 Share Posted April 13, 2013 hi Guys, I'm trying to get google analytics api libraries to work, I encounter an error that I think has something to do with my server setup - PHP Parse error: syntax error, unexpected T_CONST in /home5/virabhad/public_html/gilzehn/google-api-php-client/examples/analytics/demo/index.php on line 48 when I tried commenting our the "const" declarations and replace them with regular variables the code works (though I get errors on later stages) any help will be apreciated Quote Link to comment https://forums.phpfreaks.com/topic/276903-const-declaration-error/ Share on other sites More sharing options...
Solution salathe Posted April 13, 2013 Solution Share Posted April 13, 2013 (edited) You're using an old version of PHP (less than 5.3.0) that does not allow the const keyword outside of a class definition. Change them to use define() instead. const REDIRECT_URL = 'INSERT YOUR REDIRECT URL HERE'; // change the above to this: define('REDIRECT_URL', 'INSERT YOUR REDIRECT URL HERE'); There is a very good chance that there are other parts of the code which require PHP 5.3.0 or greater, so these constants might not be the only thing that you need to change to get the script to work on an older version of PHP. Edited April 13, 2013 by salathe Quote Link to comment https://forums.phpfreaks.com/topic/276903-const-declaration-error/#findComment-1424550 Share on other sites More sharing options...
GilZ Posted April 13, 2013 Author Share Posted April 13, 2013 Thanks, I'll just update the PHP on my server. Thats strange though as the requirements clearly state: PHP 5.2.x Quote Link to comment https://forums.phpfreaks.com/topic/276903-const-declaration-error/#findComment-1424551 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.