|
echo "This is a php string.\n"; echo 'So is this, though we'll tend to prefer double-quotes (read more below).\n'; echo "\n"; echo "Remember that spaces are just regular ol' characters (not 'nothing'), "; echo "and that the empty-string is a string (not 'nothing').\n"; echo "The length of five spaces: strlen(\" \") = ", strlen(" "); echo "The length of the empty string: strlen(\"\") = ", strlen(""); echo "The length of a string consisting of just the newline character: strlen(\"\\n\") = ", strlen("\n"); |
<?php echo "hello there everybody!"; echo ' -- Dr. Nick '; ?> |
$str = "How are you?"; $first_name = "John"; $str = "How are you " . $first_name . "?"; $str = "How are you $first_name?"; // alternately $date = "1/01/2010"; // This is a string of course, not a "date type", nor division. $str2 = "I said, \"how are you?\""; // To use a variable followed by literal-chars that aren't part of the variable name: $str3 = "Curly braces are as cute as you are, ${first_name}y-poo!"; |
here-doc strings
Actually, they come in two varieties: double-quoted, and single-quoted:
This page licensed CC-BY 4.0 Ian Barland Page last generated 2018.Jan.20 (Sat) | Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |