Home > php教程 > php手册 > body text

PHP没有?>结束标记怎么回事

WBOY
Release: 2016-05-25 16:45:27
Original
1250 people have browsed it

刚才在 segmentfault 上看到一段很不错的解释分享一下,如果使用闭合标签,任何由开发者,用户,或者FTP应用程序插入闭合标签后面的空格都有可能会引起多余的输出、PHP 错误、之后的输出无法显示、空白页,因此,所有的 PHP 文件应该省略这个 PHP 闭合标签,并插入一段注释来标明这是文件的底部并定位这个文件在这个应用的相对路径,这样有利于你确定这个文件已经结束而不是被删节的.

所以,纯 PHP 文件最好不要 ?>,不是最好,是一定.例子代码如下:

<?php 
function funa($b,$c){ 
    echo $b; 
    echo $c; 
} 
call_user_func(&#39;funa&#39;,"111","222"); 
call_user_func(&#39;funa&#39;,"333","444"); 
//结果输出:111 222 333 444
Copy after login

//大家有没有发现,这个用法有点像javascript中的call方法 

总结,php不带结束的?>还可以为避免一些编码问题导致页面出错.                                        


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!