<?php
error_reporting(E_ALL);
$great = 'fantastic';

echo "This is { $great}";

echo "This is {$great}";
echo "This is ${great}";

echo "This square is {$square->width}00 centimeters broad.";

echo "This works: {$arr[4][3]}";

// これが動作しない理由は、文字列の外で $foo[bar]が動作しない理由と同じです。
// 言い換えると、これは動作するともいえます。しかし、PHP はまず最初に foo という名前の定数を探すため、E_NOTICE レベルのエラー(未定義の定数) となります。
echo "This is wrong: {$arr[foo][3]}";

// 動作します。多次元配列を使用する際は、文字列の中では必ず配列を波括弧で囲むようにします。
echo "This works: {$arr['foo'][3]}";

// 動作します
echo "This works: " . $arr['foo'][3];
echo "You can even write {$obj->values[3]->name}";
echo "This is the value of the var named $name: ${$name}}";
/*
俺様談: 動作するはずなんだが、動作しない;やっぱり関数は定義されてないといかんのだろう
echo "This is the value of the var named by the return value(): {${getName()}}";
echo "This is the value of the var named by the return value->getName(): {${$object->getName()}}";
*/
?>