php PHP在EOT中插入变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5784637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Inserting variable inside EOT
提问by Adrian M.
I want to insert a variable inside the EOT but is not working (I am new to php, maybe that's why). This code is part of a script, when I echo $username
alone it shows the real name, but when I put it inside EOT is displaying plain text not the real name..
我想在 EOT 中插入一个变量但不起作用(我是 php 新手,也许这就是原因)。此代码是脚本的一部分,当我$username
单独回显时,它显示真实姓名,但是当我将其放入 EOT 时,显示的是纯文本而不是真实姓名。
What am I doing wrong?
我究竟做错了什么?
$username=getUsername($ID);
echo <<<'EOT'
Some HTML code goes here
Hello $username, welcome back!
Some HTML code goes here
EOT;
回答by mario
回答by s4nch3z
$variable = 'text';
echo <<<EOT
Some {$variable} here
EOT;