Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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 604
Jul 29, 2011
7,507
7,400
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 604
Jul 29, 2011
7,507
7,400
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.