要在PHP字符串中调用函数,可以使用双引号或者heredoc或nowdoc语法。例如:
$name = "John";
echo "Hello, $name!"; // 输出:Hello, John!
// 调用函数
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;
无论使用哪种方法,都可以在字符串中调用函数并输出结果。