要在PHP字符串中調(diào)用函數(shù),可以使用雙引號或者h(yuǎn)eredoc或nowdoc語法。例如:
$name = "John";
echo "Hello, $name!"; // 輸出:Hello, John!
// 調(diào)用函數(shù)
echo "Today is " . date('Y-m-d');
$name = "Alice";
$str = <<<EOD
Hello, $name!
Today is {date('Y-m-d')}
EOD;
echo $str;
$name = "Bob";
$str = <<<'EOD'
Hello, $name!
Today is {date('Y-m-d')}
EOD;
echo $str;
無論使用哪種方法,都可以在字符串中調(diào)用函數(shù)并輸出結(jié)果。