Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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 使用html更改yii中的颜色_Php_Html_Yii - Fatal编程技术网

Php 使用html更改yii中的颜色

Php 使用html更改yii中的颜色,php,html,yii,Php,Html,Yii,如何在YII视图中使用HTML更改错误的颜色 我的代码现在看起来像这样。我不确定echo和html命令如何一起使用。 foreach($InventoryModels和Results作为$result) { 回波内爆(“,”,$result[“data”])。“”; echo$result[“message”]。“”; foreach($result[“model”]->getErrors()作为$attribute=>$errors){ echo“Attribute$Attribute有以下错

如何在YII视图中使用HTML更改错误的颜色

我的代码现在看起来像这样。我不确定echo和html命令如何一起使用。 foreach($InventoryModels和Results作为$result)

{
回波内爆(“,”,$result[“data”])。“
”; echo$result[“message”]。“
”; foreach($result[“model”]->getErrors()作为$attribute=>$errors){ echo“Attribute$Attribute有以下错误:”。“
”; 回声“
    ”; foreach($errors作为$error){ 回显“
  • ”$error.

  • ”; } 回声“
”; } }
  • 你好,世界
我试过这个,效果很好

<li style='color: red;'>

  • 这很奇怪,因为在这种情况下,它应该向您显示红色文本,顺便说一句,请在浏览器中检查此css样式是否有效,并且不会改变文本的颜色。同样有效和良好的代码这是两件不同的事情,你想要模板你可以谷歌一些模板引擎为yii如果它没有提供自己的,例如我在几乎所有我的项目中使用,细枝或纯php。实际上问题是与报价。“
  • ”。我试过这个,但效果很好。嗯,我没有注意到如果你想“要回显,您需要使用反斜杠,那么它现在起作用了吗?很好,顺便说一句,我想建议检查一些视图,如twig等,因为这样显示html不是好方法。在相同的代码中,我如何计算成功和失败数据上传的总数?现在它会给我一个颜色代码,如果它失败在红色,但我想能够显示total@revuer1这取决于$result[“model”]->getErrors()数组或对象,但您可以使用类似的方法为什么不使用
    errorSummary
    ?不要在同一篇文章中复制其他人的答案。这是非常错误的,NAA。
    <li style='color: red;'>