Using TextEdit - PHP script not executing properly

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,521
22
I'm trying to write a PHP file in TextEdit.

I put this in between <?php and ?>:
Code:
echo "Hello";
When I ran the script, I got this as output: “Hello”

If I insert any non-alphanumeric character between those quotation marks, I get an error:
Parse error: parse error, expecting `','' or `';'' in /Users/montana/Sites/log-out-user.php on line 2
 

theluggage

macrumors 601
Jul 29, 2011
4,121
2,818
When I ran the script, I got this as output: “Hello”
TextEdit has 'helpfully' translated your regular ASCII quote marks (") into proper Unicode open (“) and close (”) quote marks. Looks nicer on paper - totally louses up programming languages.

TextEdit has evolved (or devolved) into a sort of word processor-lite - don't use it for programming or HTML coding.

Download a copy of TextWrangler (a free, safe bet) to get started, and should you feel the need for more bells and whistles look elsewhere in this forum for discussions on alternative HTMP/PHP/JavaScript editors and IDEs.
 

theluggage

macrumors 601
Jul 29, 2011
4,121
2,818
Make sure in the font menu in TextEdit to select "Make Plain Text".
Nope - even in "plain text" mode, TextEdit will still change "foo" to “foo”.

You need to go to preferences and turn off smart quotes, smart dashes... and preferably turn off TextEdit. The fact that, by default, TextEdit corrupts source code should be a clue that its not the tool for the job.