Parse error: syntax error, unexpected end of file on localhost - php

I had a website but is currently gone but I always had a back-up that worked on my hosting always.. I tried setting my website up on XAMPP but I keep getting the error: Parse error: syntax error, unexpected end of file.. I tried closing brackets but it didn't work. Can you guys please help me where the problem is? This is the index.php of my template where I'm getting it(backend of Joomla is doing fine):
http://pastebin.com/CzGbybYZ
Thanks.

My guess? Short tags aren't enabled, meaning the <? } ?> is not recognised as your "end of code block". Use <?php } ?> instead.

Related

Parse Error PHP Encapsed String in Magento Module

Receiving the following error while trying to register a custom Magento2 module on my local machine:
Parse error: syntax error, unexpected ''DDF_AdminMenu''
(T_CONSTANT_ENCAPSED_STRING), expecting ')' in
/Users/petey/Desktop/magento/app/code/DDF/AdminMenu/registration.php
on line 5
I can't seem to understand why I'm getting the error.
My code is the following:
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'DDF_AdminMenu',
    __DIR__
);
I know this may seem obvious but it happened to me
Please make sure you add <?php at the beginning of the file

Sudden PHP parse error on RHEL

I have various PHP files, none of which have been modified prior to the app working and it breaking. My problem is that for some reason, these files are suddenly throwing PHP parse errors for things like 'unexpected' square brackets in seemingly random places throughout the file, but upon manually checking the file, the syntax is correct.
The only thing I did that could have 'altered' the files would be various chmod operations to change the permissions. But how/why would this change the actual content of the files?
The files are called on boot just as they always have been, and have worked fine in the past, up until the recent chmod changes.
Is this permanent, or will I just have to restore my system from an earlier time?
RHEL 6.5, PHP 5.4.
Edit:
Example of the error:
PHP Parse error: syntax error, unexpected '[' in /var/ptc/CRM-dev/tools/init on line 122
What's on line 122:
$files = [];
Another example:
PHP Parse error: syntax error, unexpected '[', expecting ')' in /var/ptc/CRM-dev/vendor/react/promise/src/functions.php on line 68
What's on line 68:
return resolve([]);
But these files themselves haven't been changed (as far as I'm aware), and the syntax looks correct.
phpinfo() gives 5.4.39, which is the same as when running php -v on the server.
If the PHP version has been changed then it may be stumbling on the PHP 5.4 square bracket array syntax.
Use phpinfo(); to be sure that the PHP version running the web server is the same as the one you're using on the CLI.

PHPBB Parse error: syntax error, unexpected '}' overall_header.html.php

Hi my problem is that I am getting this error here on ym PHPBB3 website
Parse error: syntax error, unexpected '}' in /public_html/cache/tpl_anami_overall_header.html.php on line 309
It happened when I installed a mod onto PHPBB3 and it suddenly became like this.
Notes: (Things that didn't work for me)
I have tried deleting the files off the cache
I have tried restoring backups of previous dates
Also would my forum data such as posts, forums and topics be deleted if I would reinstall a new version of PHPBB3 into my directory with the same sql database? If this is possible, I would just reinstall phpbb instead
Thanks
Actually this is very simple error you are talking about. This should be solved by yourself. Use PHP Syntax Checker or other tools for this.
The cache file is generated from styles/anami/templates/overall_header.html.
Open the cache file and look at line 309, find the matching line in the file above and fix the syntax error on that line, then clear the cache.
in a text editor open styles/anami/templates/overall_header.html and check every <-- IF xxx --> and <!-- BEGIN xxx --> statement opens and closes correctly. You may find you have one too many <!-- ENDIF --> or <!-- END xxx -->

PHP adding value to array

In PHP why is this a syntax error:
$row['some_key'] = "kkkk";
Raises
Parse error: syntax error, unexpected T_STRING
From the documentation I understood this to be perfectly valid PHP, yet it throws the same error every time (and the error of course goes away then I comment the line out).
Edit: After long searching I actually noticed that the file is indeed corrupted in some way. In Vim (on ubuntu 12.04) the file looks just normal. But when viewing from other computers it's corrupted. So not related to PHP.
In PHP why is this a syntax error:
It's not. If you're getting unexpected T_STRING, the problem is elsewhere (hint: look at the line above).

Unexpected T_STRING in PHPWebSocket

I was trying to test some HTML5 WebSockets using phpwebsocket, but I got an error while trying to execute the server script:
Nathan-Campos-MacBook-Pro:socket Nathan$ php -q server.php
Parse error: syntax error, unexpected T_STRING in /Applications/XAMPP/xamppfiles/htdocs/socket/server.php on line 109
Nathan-Campos-MacBook-Pro:socket Nathan$
What I should make to correct the error?
I'm using PHP 5.3.3 and here is the content of line 109:
socket_close($user->socket);
I got the same problem. this is How I solve it. copy all the code in server.php and paste it in Eclipse in which you create a untitle php file. then you can inspect the line 109, where there are three extra dots, remove them and update what you have. i am sure this will solve it.
I think it's the format problem when you copy the server.php code. first time, I copy the code from Editor Panel, this problem was occured. so I had make a new copy from here, and successed to run the server.php :)

Categories