Jump to content

Syntax error thrown when no syntax error


wclarke

Recommended Posts

The issue is there seems to be NO syntax error.

1. There is no relevant code before or after this line. 2. Yes, one would think a ! should be there as did I (I didn't write the code), however, even with the ! it still gives the same error.

if (function_exists('gzcompress')) die(FUNCTION_NOT_FOUND); is giving me a

syntax error, unexpected 'if', expecting 'function' or 'const'

I am updating this code from PHP5.3 to PHP7.4 and I can't figure out what the syntax problem is since PHP allows this. I am using Eclipse PHP to do the conversion.

Link to comment
Share on other sites

PHP saying there is a syntax error on line X doesn't necessarily mean that the error is actually on line X.  It could in fact be anywhere from line 1 through X.

The line PHP reports is just where PHP finally realized there is a problem.  With issues such as missing quotation marks or missing closing braces PHP will be able to continue parsing the source for quite a while before realizing something is amiss.  Most of the time, the line number reported gets you close, but if nothing appears wrong there you need to start back tracking until you figure it out.

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.