Escape character in php

Status
Not open for further replies.


correct.

Code:
$str = "rembrant's incredible website";
$str = 'rembrant\'s incredible website';

either of those are valid.
 
Something to keep in mind as you decide which quotes to use...

With double quotes, you can put variables inside them and they'll get resolved. With single quotes they won't.

$str1 = "lamb";
$str2 = "Mary had a little $str1";
echo $str2;

outputs: Mary had a little lamb

$str2 = 'Mary had a little $str1;

outputs: Mary had a little $str1
 
In some programming languages you're supposed to use the single quote for a char and double quotes for a string. I'm assuming from use this doesn't hold true in PHP. does anyone know otherwise?
 
I've heard the 'proper' way of doing things is to use singlequotes.

Code:
echo 'this is "something" that is ' . $awesome;
 
Status
Not open for further replies.