PHP表单 - 格式回声语句输出

时间:2014-01-23 23:03:44

标签: 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 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();

    }

第一个和第三个echo语句输出html格式,但是如何获得中间$ error语句输出漂亮的html?

2 个答案:

答案 0 :(得分:1)

类似的东西:

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

答案 1 :(得分:0)

试试这个:

<?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();
}

?>