I have a weird PHP error in a current Symfony2 project:
unexpected T_STRING in /blahblah/Foo/BarBundle/Entity/User.php on line 1
This is a pretty standard error, usually linked to a mismatched pair of " or '.
But here is the code of the file User.php
<?php
namespace Foo\BarBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
* @ORM\Entity(repositoryClass="Foo\BarBundle\Entity\UserRepository")
*/
class User extends \FOS\UserBundle\Entity\User
{
// classic user entity
The line <?php is line #1. There is no quotes, and the weird thing comes from the fact that this error only appear on my staging server: on 2 development machines with local copies of the code, it behaves as expected with no error or warning. The file is the correct one, the cache was emptied. I thought that it might be an encoding error but it does not seem to be this. I also thought of namespace issues, but the PHP version on the server is correct (5.3.16)
Do you have any idea what this error can stem from, or in which direction I could search ? Thanks in advance.
Most coding conventions that I worked with strictly require using
LF
('Unix style','\x0A'
) line endings in the scripts. And whoever managed to submit code withCRLF
or, god forbid,CR
had to endure a royal share of pain. )It may seem not such a big deal, yet it can save you hours of searching for a weird error - such as in this case.
I think it's an encoding problem of your file. If your project is encoded UTF8 for example, open your file with your text editor and choose the option "Encoding" -> UTF-8 without BOM.