Double quotes within php script echo(php脚本中的双引号echo)
本文介绍了php脚本中的双引号echo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一行 php 代码,如下所示:
I have a line of php code that looks like this:
echo "<script>$('#edit_errors').html('<h3><em>Please Correct Errors Before Proceeding</em></h3>')</script>";
我想知道如何正确地为文本添加字体颜色.如果我这样做:
I would like to know how to add a font color to the text correctly. If I do this:
echo "<script>$('#edit_errors').html('<h3><em><font color="red">Please Correct Errors Before Proceeding</font></em></h3>')</script>";
red"这个词是黑色的,编译器会报错.
The word "red" is in black text and the compiler throws an error.
如果我在红色周围使用单引号,则文本根本不会显示.
If I use single quotes around red, then the text does not show up at all.
任何帮助都会很棒.谢谢
Any help would be great. Thanks
推荐答案
你需要转义 "
,所以它不会被解释为字符串的结尾.使用 逃避它:
You need to escape "
, so it won't be interpreted as end of string. Use to escape it:
echo "<script>$('#edit_errors').html('<h3><em><font color="red">Please Correct Errors Before Proceeding</font></em></h3>')</script>";
阅读更多:字符串 和 转义序列
这篇关于php脚本中的双引号echo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:php脚本中的双引号echo


猜你喜欢
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01