Reputation: 1199
I can't parse properly using Text Editor because it interprets the apostrophe key on my keyboard as a single quote (‘ - slanted). PHP requires an apostrophe (' - straight). When I press this key anywhere else (browser, etc. it displays as an apostrophe.
Works - <?php echo '<p>Hello World</p>'; ?>
Doesn't work - <?php echo ‘<p>Hello World</p>’; ?>
How can I get Text Editor to display the straight apostrophe instead of a single quote?
Upvotes: 0
Views: 1822
Reputation: 12287
It sounds like you have TextEdit in rich text mode. This will only cause you horrible pain trying to write code.
You can use Shift+Cmd+T, or the menu item Format -> Make Plain Text
if you're editing code.
There are better choices for code editors on OSX though, like TextWrangler, which is free.
Upvotes: 1
Reputation: 1
Try changing the font to Arial, I just checked and it appears to use the apostrophe instead of the single quote, when I copied and pasted the example it recognized both characters
Upvotes: 0
Reputation: 20286
You won't change PHP syntax unless you wan't to write your own interpreter :P
If you want to display for user an apostrophe you need to escape it with \'
Moreover, you can echo string also with double quote so:
<?php echo '<p>Hello World</p>'; ?>
<?php echo '<p>\'Hello World\'</p>'; ?>
<?php echo "<p>Hello World</p>"; ?>
will work.
You will find more information about strings here
Upvotes: 0