In both types of string:
' needs to be \'
\ needs to be \\
In ” ” strings:
" needs to be \"
\n new line
Note, using say ‘\n’ will not create a newline character, it will create the characters \n !!!!! \n only works in a “” string!!
Use the period character ‘.’
You can also use .=
$body = "Some text"; $body .= "Some more text";
Is String Empty
$my_string = trim($my_string); if (!empty($my_string)) //Do something
$length = strlen($MyString);
‘ vs “
‘ single quotes assigns a string using its exact contents. So if you want to include variables you have to do this:
echo 'His name is ' . $name . ' and his age is' . $age';
” double quotes assigns a string but if the string contains a variable name the php parser will attempt to evaluate it, so you can use it like this:
echo "His name is $name and his age is $age";
Echo A Block Of Text
echo "Some text blah blah";