Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does pasting a line break the code if writing out the same line by hand works fine?

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

First version:

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

Second version:

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

Although they look identical, the first version results in a PHP Parse error: syntax error, unexpected T_STRING, whereas the second version works fine. The difference between the two is that the first version was pasted in and modified whereas the second version was written out by hand entirely. What's going on here?

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

like image 254
Shawn Avatar asked Mar 22 '13 14:03

Shawn


1 Answers

You've copied UTF-8 quote marks, which are not parse-able by PHP. Remove the quote marks and replace them with ASCII equivalents (i.e. by typing them).

For more information on ASCII vs UTF-8 quote marks see http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

like image 167
Jon Cairns Avatar answered Sep 22 '22 05:09

Jon Cairns