Laravel在Doctype之前显示一个空行 [英] Laravel displays an empty line before the Doctype

查看:107
本文介绍了Laravel在Doctype之前显示一个空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <!DOCTYPE html> 

这是代码。



我可以解决这个问题吗?



在将代码与Laravel集成之前,我测试了HTML / CSS / JavaScript。 >解决方案

确保你的PHP文件没有结束标记(?> )。他们可能会将空格添加到您的HTML中。



更多信息,查看PHP文档
$ b


如果一个文件是纯PHP代码,最好在文件末尾省略PHP结束标记。这可以防止在PHP结束标记后添加意外的空白或新行,这可能会导致不必要的效果,因为当程序员没有意图在脚本中发送任何输出时,PHP将开始输出缓冲。







您可能还想看看这篇文章:为什么会忽略关闭标记?


<!DOCTYPE html>

This is the code.

How can I fix that?

I tested the HTML/CSS/JavaScript before integrating the code with Laravel.

解决方案

Make sure your PHP files don't have the closing tags (?>). They might add whitespace to your HTML.

For more info, see the PHP docs:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.


You might also want to take a look at this post: Why would one omit the close tag?

这篇关于Laravel在Doctype之前显示一个空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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