add more information for strings

This commit is contained in:
Tamnac 2023-07-22 21:01:36 -07:00 committed by GitHub
parent e4f276b51c
commit cc6c14ba99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,9 +92,10 @@ $escaped = "This contains a \t tab character.";
$unescaped = 'This just contains a slash and a t: \t'; $unescaped = 'This just contains a slash and a t: \t';
// Enclose a variable in curly braces if needed // Enclose a variable in curly braces if needed
$apples = "I have {$number} apples to eat."; $number = 23;
$oranges = "I have ${number} oranges to eat."; $apples = "I have {$number} apples to eat."; // => I have 23 apples to eat.
$money = "I have $${number} in the bank."; $oranges = "I have ${number} oranges to eat."; // => I have 23 oranges to eat.
$money = "I have $${number} in the bank."; // => I have $23 in the bank.
// Since PHP 5.3, nowdocs can be used for uninterpolated multi-liners // Since PHP 5.3, nowdocs can be used for uninterpolated multi-liners
$nowdoc = <<<'END' $nowdoc = <<<'END'
@ -109,7 +110,7 @@ $sgl_quotes
END; END;
// String concatenation is done with . // String concatenation is done with .
echo 'This string ' . 'is concatenated'; echo 'This string ' . 'is concatenated'; // Returns 'This string is concatenated'
// Strings can be passed in as parameters to echo // Strings can be passed in as parameters to echo
echo 'Multiple', 'Parameters', 'Valid'; // Returns 'MultipleParametersValid' echo 'Multiple', 'Parameters', 'Valid'; // Returns 'MultipleParametersValid'