简体   繁体   English

需要帮助回声不显示任何结果

[英]Need help echo not show any result

Hi all php expert i want to know the reason if i user the following line of code 大家好,PHP专家,我想知道如果我使用以下代码行的原因

echo '<text';

echo "<text";

above line of code will result blank. 上面的代码行将为空。

Can any php expert could face that issue. 任何PHP专家都可以面对这个问题。 Need reason 需要理由

It's because you are echoing start of HTML tags (like <div class="a" ). 这是因为您正在回显HTML标记的开始(例如<div class="a" )。 No error will ever be thrown by HTML. HTML不会抛出任何错误。 Replace < with &lt; <替换为&lt; and > with &gt; >&gt; to break HTML parser. 破坏HTML解析器。

这样写

echo '&lt; text';

Try this Its working : 试试这个它的工作:

<?php
echo '&lt; text';
?>

If you write < in echo statement after the ' or " behaves as a HTML tag.HTML tag not displayed to the user that's why it always result you blank. 如果你写<表现为一个HTML标记tag.HTML后echo语句不显示,这就是为什么它总是导致您空白的用户。

If you try to output plain text, place the following in the beginning of your script 如果您尝试输出纯文本,请将以下内容放在脚本的开头

header('Content-Type: text/plain; charset=UTF-8');

After that you will see symbols just fine. 之后,您将看到符号就好了。

PHP echoing < as open html tag if it follows by letters. 如果PHP后面跟随字母,则将<作为开放html标记回显。 So just add a space after < 因此,只需在<

<?php
echo '< text';
?>

you can use > as you like 您可以根据需要使用>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM