在 PHP 中,为什么 </script>不显示解析错误? [英] In PHP, why does </script> not show a parse error?

查看:38
本文介绍了在 PHP 中,为什么 </script>不显示解析错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下 PHP 代码:

I was running the following PHP code:

<?php 
    </script>
?>

没有解析错误,输出是?>"(示例).

There were no parse errors and the output was "?>" (example).

在类似的情况下,我确实收到解析错误:

In similar cases I do get a parse error:

<?php 
    </div>
?>

?>

<块引用>

解析错误:语法错误,意外的<"在...

Parse error: syntax error, unexpected '<' in ...

为什么<?php </script>?> 给出同样的错误?

Why doesn't <?php </script> ?> give the same error?

推荐答案

这一定是因为 有多种方法可以启动一段 PHP 代码:

  • <代码>(称为 short_open_tag)

<?php ... ?>(真正的标准)

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆