Unexpected end of file on custom Woocommerce template [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I'm coding a custom Woocommerce theme. All works well in local, but when I deploy on my server, this error occurs when I go to a product details:
Parse error: syntax error, unexpected end of file in /wp-content/themes/customtheme/content-single-product.php on line 231
Here's the concerned file code (Pastebin since it's a big amount of code and it display the lines number) : https://pastebin.com/bzgLQTmD
I really don't know where is this error given that I don't have it in local development.
I tried code validators, but they didn't gave me any clues.

The problem is with short tags, which are not enabled by default. So, either enable them from php.ini or
Change all of these:
<? endif; ?>
To Proper full tags like:
<?php endif; ?>

Related

Why am I receiving this compiler error. The syntax appears correct to me [duplicate]

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!

Wordpress: Shortcode Error in PHP: syntax error, unexpected '1' (T_LNUMBER) [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
Hi I was told to put the following code into my footer PHP
<?php echo do_shortcode("[wpgmza id="1"]"); ?>
My acutal code:
<div class="col-lg-8"><?php echo do_shortcode("[wpgmza id="1"]"); ?> </div>
Im getting the following Error:
Your PHP code changes were rolled back due to an error on line 142 of file wp-content/themes/XXXX/footer.php. Please fix and try saving again.
syntax error, unexpected '1' (T_LNUMBER)
Why is this happening when most forums i read say to that following code?
You are not escaping the quotes in the string and so the string itself ends just before the 1.
What your code is seeing
<?php echo do_shortcode("string"1"string"); ?>
To fix you can change it to single quotes.
<?php echo do_shortcode('[wpgmza id="1"]'); ?>
Here is more info on escaping strings https://www.php.net/manual/en/language.types.string.php

WordPress site not launching because of a PHP error [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I haven't opened my main domain for a month or so, and when I did, I got this error:
Parse error: syntax error, unexpected '.', expecting ')' in /home2/navidcs/public_html/4amir.com/wp-content/plugins/mojo-marketplace-wp-plugin/inc/cli-init.php on line 25
My site is based on WordPress, and I have never edited the PHP files, though I have messed around a lot with one of my sub domains, which is also using WordPress, but should not be related to my main domain.
Here is the link to the file that apparently has the error:
https://codeshare.io/Amirak
In PHP, "." is the concatenation operator. Normaly, you can break the line before or after this operator...
Please, try to replace
'longdesc' => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' .
PHP_EOL . 'Subcommands: update, remove',
by
'longdesc' => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' . PHP_EOL . 'Subcommands: update, remove',
and give the new error message.

vqcache/vq2-catalog_controller_common_header.php [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am receiving this error message:
[17-Mar-2017 10:22:14 America/Detroit] PHP Parse error: syntax error, unexpected end of file in /home/smarthea/public_html/ocart/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 50
Here is the end of my code in the vqcache PHP file:
$this->template = 'default/template/common/header.tpl'; }
{ $this->render(); }
?>
Which syntax am I missing?
See you modification-file. You just missed line number. Just look into instructions in modificator and correct it.
This error usually appear when you're using several vQmod mofificators that used same file. In you case they modify /catalog/controller/common/header.php

PHP: if { } parse error [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I'm using this to determine if a variable is set. I am not a beginner and normally, this works (it's not complicated either)...
if(isset($ok)) { 
[stuff happening]
}
This is the return:
Parse error: syntax error, unexpected '}' in firstlaunch.php on line 6
The thing is, that's that. My file is empty but for those few lines. I'm used to fixing those types of problems but I can't see why the error is coming since that's the only PHP on my page.
Ideas?
Thanks a lot!
++++++
Edit: the full script is:
<?php
$ok = isset($_GET['flag']);
if(isset($ok)) { 
}
?>
Ok guys, thanks a lot for the HEX editor suggestion, it worked: I had this thing between my { }:
 
Wonder where that came from... But now my file executes!
Thanks!

Categories