This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I am trying to fopen() a debugging text file, which I have simply named debug.txt and put it on my desktop. I am using PHP. My code is simply
$debug_file = fopen( "C:\\Users\\joe\\Desktop\\debug.txt", "w" );
I keep getting this error
Parse error: syntax error, unexpected '$debug_file' (T_VARIABLE) ` on line 755, which is the line of code above.
I have checked the code before this line for a missing semicolon, as that often is the source of a syntax error, but the previous code is fine. If I comment out my one line of code, the PHP file no longer gives a syntax error.
I was thinking that there is something wrong with the way I write the string literal file path to open. I have tried to make it ok by escaping the backslashes. I'm using Windows 10. But that hasn't fixed the problem. For the life of me I can't figure out what the syntax error is.
Thanks for any help.
EDIT: As requested, the previous lines of code are:
add_shortcode('hide-it', 'hide_it_func');
function hide_it_func(){
return;
}
The problem is the line(s) above, you either didn't end it with a semicolon or there's an open bracket, or something along those lines.
Related
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 months ago.
Just started learning PHP out of curiosity. Currently going through all basic fundamentals in PHP and that's when I came across this function define that we do use to define variables with constant values. However, instead of showing me an expected output, it's giving me unexpected result. Can anybody help me?
define('HOST', 'localhost'); // syntax error, unexpected identifier "define", expecting "," or ";"
define('USER', 'root');
With the limited information given in this post, i only see two point where the issue might hide.
You forgot to start your php code with a <?php start tag
You have some php code above the snippet you posted that is missing it's ;(semicolon) on the end of it's line. Good hunting :-)
Hope this helps :-)
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
I'm receiving the following error on my wordpress site:
An error of type E_PARSE was caused in line 56 of the file /var/www/compass.valuescentre.com/wp-content/plugins/woocommerce/woocommerce.php. Error message: syntax error, unexpected ':', expecting '{'
Below is my code from line 56-58:
function wc_get_container() : \Psr\Container\ContainerInterface { return $GLOBALS['wc_container']; }
A compiler gets problems on the exact location of a missing ),},; or ].
I would advice you to look if you missed any closing tags in the lines before 56.
if you whant to make that fast, maybe go with control + f to look for the amount of opening brakets and see if it matches the closing ones?
good luck!
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
last "}" is line 762. log says "PHP Parse error: syntax error, unexpected '}' in /home/u230748479/public_html/application/controllers/api_new.php on line 762" if you need whole code ill send you. please help me. thanks.
https://drive.google.com/open?id=0B6DjyTFNtfv5SjZBM2JGNVh2V2c
link to my php file
There is nothing wrong with your code, but you got 3 invalid (\u007F) characters before the } that gives the error.
This is your code
echo "1";
}
// this line contains 3 invalid characters (\u007F = DELETE character)
} // this is line 762
Remove the line with the invalid characters and you should be good to go.
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
The error is:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home2/svchapel/public_html/mmp_upgrade/administrator/components/com_sermonspeaker/s3/S3.php on line 1802
The line of code referenced is:
'code' => (string)$rest->response->body->Error->Code,
The line above the code referenced is:
$rest->response->error = array(
And the line below the code referenced is:
'message' => (string)$rest->response->body->Error->Message);
I can't find a problem in any of these lines... help?
Might be some odd, but invisible character there which ruins the PHP syntax (e.g., some sort of a fancy hyphen character instead of a regular one). I would try carefully re-typing the whole line manually in the plain text editor; if that doesn't help, I'd try to insert line breaks before each -> to see where exactly PHP borks up.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Reference - What does this error mean in PHP?
I keep on getting a "Parse error: syntax error, unexpected '(', expecting T_VARIABLE or '$' in..."
Here's the line thats causing the problem, not sure whats going on here?
$text = "<script>window.setInterval(function(){$('#liveData').load('liveUpdate.php');}, 1000);</script>";
Thanks in advance
You should escape $ in your $text
$text = "<script>window.setInterval(function(){\$('#liveData').load('liveUpdate.php');}, 1000);</script>";
Or you just use single quote.
Because $ in double quote will be followed by a php variable name, $(XXXX is an invalid PHP variable.
So the best way is to separate javascript (jquery) into a .js file.
Try this,
$text = '<script>window.setInterval(function(){$("#liveData").load("liveUpdate.php");}, 1000);</script>';
$text = '<script>window.setInterval(function(){$("#liveData").load("liveUpdate.php");}, 1000);</script>';