This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
It used to be hard to find questions about operators and other syntax tokens.¹
The main idea is to have links to existing questions on Stack Overflow, so it's easier for us to reference them, not to copy over content from …
这是根据官方文档的信息:
可以在PHP中使用四对不同的开始和结束标记.其中两个,
<?php ?>并且<script language="php"> </script>始终可用.另外两个是短标签和ASP样式标签,可以从php.ini配置文件打开和关闭.因此,虽然有些人发现短标签和ASP样式标签很方便,但它们的便携性较差,一般不推荐.
在我的经验,大多数服务器都启用短标记.打字
<?=
Run Code Online (Sandbox Code Playgroud)
打字要方便得多
<?php echo
Run Code Online (Sandbox Code Playgroud)
程序员的便利是一个重要因素,为什么不推荐他们?