Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表单格式Echo语句输出_Php_Html_Forms - Fatal编程技术网

PHP表单格式Echo语句输出

PHP表单格式Echo语句输出,php,html,forms,Php,Html,Forms,我正在做一份php5表格。 以下是功能代码: function died($error) { // your error code can go here echo "<div style ='background-color:green;font:22px Arial,tahoma,sans-serif;color:#ff0000'>We are very sorry, but there were error(s) found with the

我正在做一份php5表格。 以下是功能代码:

function died($error) {

        // your error code can go here

        echo "<div style ='background-color:green;font:22px Arial,tahoma,sans-serif;color:#ff0000'>We are very sorry, but there were error(s) found with the form you submitted.<br /><br />
These errors appear below.<br /><br /></div>";

        echo "<br /><br />";
        echo $error."<br /><br />";

        echo "<div style ='background-color:green;font:22px Arial,tahoma,sans-serif;color:#ff0000'>Please go back and fix these errors.<br /><br /></div>";

        die();

    }
函数失效($error){
//您的错误代码可以转到这里
echo“非常抱歉,您提交的表单有错误。

这些错误如下所示。

”; 回声“

”; echo$错误。“

”; echo“请返回并修复这些错误。

”; 模具(); }
第一个和第三个echo语句输出html格式,但是如何让中间的$error语句输出漂亮的html呢

试试这个:

<?php

function died($error) {
echo <<< EOF
<div style ='background-color:green;font:22px Arial,tahoma,sans-serif;color:#ff0000'>We are very sorry, but there were error(s) found with the form you submitted.<br /><br />
These errors appear below.<br /><br /></div>
<br /><br />
$error.<br /><br />
<div style ='background-color:green;font:22px Arial,tahoma,sans-serif;color:#ff0000'>Please go back and fix these errors.<br /><br /></div>
EOF;
die();
}

?>

这样做:

 echo "<div style ='background-color:red;'>".$error."</div>"
echo.“$error”