Why does line insertion interrupt code if writing a single line manually is perfect?

Here are two versions of the line in the php file:

First version:

if ($projet['sourceDonnees'] === (string)$CONSTANTS['sourceDonnees_saisie']) {

Second version:

if ($projet['sourceDonnees'] === (string)$CONSTANTS['sourceDonnees_saisie']) {

Although they look the same, the first version results in PHP Parse error: syntax error, unexpected T_STRING, while the second version works fine. The difference between the two is that the first version was inserted and modified, and the second version was completely written out manually. What's going on here?

Notes : the line was copied from a text file encoded in UTF-8 and pasted into another text file UTF-8. All operations are performed in gedit, both files written by me in gedit.

+5
source share
3 answers

"show invisible characters", :

enter image description here

if ($projet['sourceDonnees']•=== (string)$CONSTANTS['sourceDonnees_saisie']) {

] ===.

.

-. , , .

"-ASCII"... BBEdit "" "zap gremlins".

+3

UTF-8, PHP. ASCII (.. ).

ASCII UTF-8 . http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

+5

unexpected T_STRINGusually a problem with your quotes or marks. 'in the code you copied is UTF-8 and probably the version of the quote that PHP cannot parse, like the backlinks that we use for the inline code here on SO. Try changing them to a regular single quote and this will most likely solve your problem.

If this is not the case, make sure you do not skip the semicolon at the end of your function. This can lead to the same error.

0
source

All Articles