diff --git a/language/types/string.xml b/language/types/string.xml index 147256930682..fcfb74084454 100644 --- a/language/types/string.xml +++ b/language/types/string.xml @@ -942,10 +942,13 @@ $arr = [ ]; // Won't work, outputs: This is { fantastic} -echo "This is { $great}"; +echo "This is { $great}" . PHP_EOL; // Works, outputs: This is fantastic -echo "This is {$great}"; +echo "This is {$great}" . PHP_EOL; + +// To show curly braces in the output: +echo "This is {{$great}}" . PHP_EOL; class Square { public $width; @@ -956,31 +959,31 @@ class Square { $square = new Square(5); // Works -echo "This square is {$square->width}00 centimeters wide."; +echo "This square is {$square->width}00 centimeters wide." . PHP_EOL; // Works, quoted keys only work using the curly brace syntax -echo "This works: {$arr['key']}"; +echo "This works: {$arr['key']}" . PHP_EOL; // Works -echo "This works: {$arr[3][2]}"; +echo "This works: {$arr[3][2]}" . PHP_EOL; -echo "This works: {$arr[DATA_KEY]}"; +echo "This works: {$arr[DATA_KEY]}" . PHP_EOL; // When using multidimensional arrays, always use braces around arrays // when inside of strings -echo "This works: {$arr['foo'][2]}"; +echo "This works: {$arr['foo'][2]}" . PHP_EOL; -echo "This works: {$obj->values[3]->name}"; +echo "This works: {$obj->values[3]->name}" . PHP_EOL; -echo "This works: {$obj->$staticProp}"; +echo "This works: {$obj->$staticProp}" . PHP_EOL; // Won't work, outputs: C:\directory\{fantastic}.txt -echo "C:\directory\{$great}.txt"; +echo "C:\directory\{$great}.txt" . PHP_EOL; // Works, outputs: C:\directory\fantastic.txt -echo "C:\\directory\\{$great}.txt"; +echo "C:\\directory\\{$great}.txt" . PHP_EOL; ?> ]]>