Jump to content

"const" declaration error


GilZ
Go to solution Solved by salathe,

Recommended Posts

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

Link to comment
Share on other sites

  • Solution

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 by salathe
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.