Php HTML中的变量
我这里有一个函数,它基本上是在不破坏布局的情况下存在的:Php HTML中的变量,php,Php,我这里有一个函数,它基本上是在不破坏布局的情况下存在的: function bomb($str,$wrap) { $error = $str; echo $wrap; include_once '../include/foot.php'; exit(); } 然后我声明了一个长HTML: $signup= 我明白你想做什么。但是,$signup的内容已经存储,您不能将$error“传入”$wrap,否则会将变量作为参数传入函数中 试试这个: function b
function bomb($str,$wrap) {
$error = $str;
echo $wrap;
include_once '../include/foot.php';
exit();
}
然后我声明了一个长HTML:
$signup=
我明白你想做什么。但是,$signup的内容已经存储,您不能将$error“传入”$wrap,否则会将变量作为参数传入函数中
试试这个:
function bomb($str) {
echo msg($str);
include_once '../include/foot.php';
exit();
}
function msg($error) {
$signup = <<<HTML
blah Blah blah
<span>$error</span>
blah blah blah
HTML;
return $signup;
}
功能炸弹($str){
echo msg($str);
include_once'../include/foot.php';
退出();
}
函数msg($error){
$signup=所以这是不可能的?有什么办法解决这个问题吗?我也尝试在heredoc中使用$str
,而不是$error
,但这也不起作用。谢谢,我会在回家后试一试。:)谢谢!它起作用了,但我希望bomb函数中有另一个变量,我可以选择执行哪个函数。
function bomb($str) {
echo msg($str);
include_once '../include/foot.php';
exit();
}
function msg($error) {
$signup = <<<HTML
blah Blah blah
<span>$error</span>
blah blah blah
HTML;
return $signup;
}