Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: sinip (31.223.135.---)
Date: January 15, 2017 11:18PM

Hello, I'm experiencing the error as in the subject.

My configuration

Windows 10 x64 1607
Wamp 3.0.8 x64
Apache 2.4.23
PHP 5.6.25
MySQL 5.7.14

Icon is Green, all is ok, localhost is reachable, phpMyAdmin works as well

Path is C:\wamp64\
Antivirus is standard one that came with Win10 - Windows Defender


This is the situation:
I've installed WordPress 4.7.1 installation went without issues, WordPress is accessible and works without any errors.
Then I've tried to add one theme and after adding it, if I go to Appearance->Themes and click on Live Preview I get

( ! ) Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION) in C:\wamp64\www\wordpress\wp-content\themes\streamstore-6rZhg3-pLPPrG\inc\options.php on line 1767

However, I've installed the theme without any issue on my shared hosting that has the following characteristics:
Apache Version 2.2.27
PHP Version 5.4.30 (native), switched to 5.6.29 in cPanel
MySQL Version 5.5.52-cll

Obviously, the environment differs but what's exactly the culprit is beyond me. I'd really appreciate any help in resolving this.

Best regards!

Options: ReplyQuote
Re: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: RiggsFolly (Moderator)
Date: January 16, 2017 11:22AM

Hi,

This is a PHP error message and is related to you WordPress installation.

I am afraid this is not a WAMPServer issue.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: sinip (31.223.135.---)
Date: January 16, 2017 01:52PM

Might be. I was actually thinking that it is related to PHP version in use but then again I have the same WordPress install on shared hosting and the theme works, which brings me back to Wamp environment.

Options: ReplyQuote
Re: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: RiggsFolly (Moderator)
Date: January 16, 2017 04:19PM

OK, So what version of PHP is running on WAMPServer and what version of PHP is running on your other environment?

Again, picking a compatible version of PHP is not a WAMPServer issue, its down to you to pick a compatible version, there are lots available as ADDON's for you to do exectly this.

See [forum.wampserver.com]
and [wampserver.aviatechno.net] for a easy to see set of ADDONS

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 01/16/2017 04:19PM by RiggsFolly.

Options: ReplyQuote
Re: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: sinip (31.223.135.---)
Date: January 18, 2017 01:27PM

As I've stated in the opening post, host's version is 5.6.29 while Wamp's version is 5.6.25.

But that wasn't the issue.

The issue was bad programming. smiling smiley It seems that Wamp is much more strict when it comes to syntax than hosting, and the programmer who made the theme was often using <? instead of <?php and also often without trailing space.
Once I've fixed those issues the theme started working in Wamp as well.

Options: ReplyQuote
Re: Parse error: syntax error, unexpected '?>', expecting function (T_FUNCTION)
Posted by: RiggsFolly (Moderator)
Date: January 18, 2017 02:33PM

For reference: PHP 5.6.29 is available as an ADDON See above links.

PHP5.6.25 comes with

short_open_tag = Off

set in the `php.ini` file.

This can be chnaged to
short_open_tag = On

And the short tags i.e.
<?
will work as your programmer intended.


I think your issue is more to do with your lack of experiece than your programmers mistakes. Remember now you have WAMPServer installed you are now the SYSADMIN, DBADMIN, WEBADMIN etc etc Lots and lots to learn

But good luck.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.