Skip to content

Instantly share code, notes, and snippets.

@sirkitree
Forked from toddota/strings.php
Created July 28, 2011 02:11
Show Gist options
  • Save sirkitree/1110782 to your computer and use it in GitHub Desktop.
Save sirkitree/1110782 to your computer and use it in GitHub Desktop.
PHP Learning
<html>
<body>
<p> Jeff Buckley is playing on the radio, and I like it. </p>
<p> It's John's birthday. He's so old! </p>
<?php print "Jerad said, \"Awesome!\" in response to my last assignment."; ?>
<?php print 'But this one I didn\'t quite get at first.'; ?>
<p> Using Github to host these code snippets will work well. </p>
</body>
</html>
@sirkitree
Copy link
Author

So you can see here, that if you're using doube quotes to print a string, and you want the result of the print statement to actually print out any double quotes as well, you must first escape them with a backslash.

The same goes for the single quote.

But you are correct in that you do not have to escape a double quote if your print statement is using single quotes. Nor vice-versa.

@toddota
Copy link

toddota commented Jul 28, 2011

Ahh- I see!! I actually had the the top red line right at first but then I changed it cause I thought it was only with single quotes. Sweet. Thanks for clarifying Jerad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment