我正在尝试在php中输出变量的字符串值
// sanitizes the string value that's passed in from the sending page
$cmessage = filter_var($_POST["confmsg"], FILTER_SANITIZE_STRING);
$output = json_encode(array('type'=>'message', 'text' => "<div style='margin-bottom: 7px; clear:right;'>" . $user_name . ': </div>echo "$cmessage"'));
$output
在发送页面的警报中显示,但以文字形式显示。
例子:Joe: echo $cmessage
我需要怎么做$cmessage
才能显示的字串?
这是因为您弄乱了单引号和双引号,请尝试以下操作:
// sanitizes the string value that's passed in from the sending page
$cmessage = filter_var($_POST["confmsg"], FILTER_SANITIZE_STRING);
$output = json_encode(array('type'=>'message', 'text' => "<div style='margin-bottom: 7px; clear:right;'>$user_name:</div>$cmessage"));
编辑:这将是一个更好的人,而且您更容易理解
// sanitizes the string value that's passed in from the sending page
$cmessage = filter_var($_POST["confmsg"], FILTER_SANITIZE_STRING);
$output = json_encode(array('type'=>'message', 'text' => "<div style='margin-bottom: 7px; clear:right;'>".$user_name.":</div>".$cmessage));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句