2

Could someone give me a pointer on what could be wrong here:

File f1.php:

<?php

include('f2.php');

File f2:

<?php
echo "HERE";

Error reported:

`Parse error: syntax error, unexpected '=' in f1.php on line 4`
  • Using php-fpm 5.4 on nginx 1.2.6.
  • Files have no BOM marker.
  • The server has no hardware issues.

It's probabbly a configuration issue, but i just can't seem to figure it out.

I've asked this question a few minutes ago, but got instantly closed as too localized as I was referencing a situation in my project and not a specific situation (https://stackoverflow.com/questions/14651673/strange-php-syntax-error-issue)

UPDATE: Obviously not related to nginx ... same error if executed in cli

13
  • 2
    Do you have any php configuration that is auto prepending a file to all requests? Commented Feb 1, 2013 at 18:03
  • Parse error: syntax error, unexpected '=' in f1.php on line 4 -- f1.php only has 3 lines, but errors on line 4? Commented Feb 1, 2013 at 18:06
  • @user2023235: the f1 has 4 lines, f2 has 3 lines Commented Feb 1, 2013 at 18:07
  • @Jure Kajzer what is on line 4 of f1.php. Your code sample only has 3 lines Commented Feb 1, 2013 at 18:09
  • @datasage: no, noprepending Commented Feb 1, 2013 at 18:10

2 Answers 2

2

Seems i've solved it ...

Short story:
Recompiled PHP with --enable-zend-multibyte.

Long story:
I tried everything imaginable ... checked source files byte-by-byte and there were no issues to be found. I've tried getting file contents inside php and echoing byte array from insidde php and in this case too, no issues to be found.
I've tried recompiling php with debugging symbols, but the process finished with 0377 and gdb had nothing useful to offer.

No matter what i did, uppon hitting an include statement (or variants of it) i got the syntax error on line past last of the included file.

I would expect the files having BOM (as suggested by almost everyone i've asked). So i thought it had to be something with how php was being run and tried changing environment variables (like LC_* vars) but again no results.

So i the end i had an add-configure-option-and-recompile-php session ... not sure exactly why as all of the scripts contain no multibyte chars and as stated before no BOM marker, but after recompiling PHP with --enable-zend-multibyte, the code started to work as expected.

Thanks to all for suggestions.

Sign up to request clarification or add additional context in comments.

2 Comments

that's a bit late to ask now, but have you tried to save your .php files with the windows notepad in ascii mode only? that would have cleaned every multibyte char inside of them
@link: as i've said the files have been checked with a hex editor, byte by byte, there were no multibyte chars in the files.
0

If you are using APC probabily you don't have updated the previous byte code.

Try apc_clear_cache();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.