是否可以在 php 文件中包含 html 文件 [英] Is it possible to include an html file inside a php file

查看:42
本文介绍了是否可以在 php 文件中包含 html 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 php 文件中包含一个 html 文件,我尝试在 php 文件中使用 includerequire,但没有应用 css 样式,只有内容是包括.有没有办法包含带有样式和 jquery 的完整 html 文件?

I need to include a html file inside a php file, I tried using include and require in php file, but css styles are not applied and only the content is included. Is there a way to include the full html file with styles and jquery?

推荐答案

没有 PHP 脚本之类的东西.只是碰巧包含 PHP 代码块的文件.你可以 include() 任何你想要的东西,但除非包含的文件在某处有一个 <?php ... ?> 块,否则文件的内容将简单被视为输出.

There's no such thing as a PHP script. There's just files that happen to contain PHP code blocks. You can include() anything you want, but unless that included file has a <?php ... ?> block in it somewhere, the file's contents will simply be treated as output.

如果没有应用 css,请确保您的样式表正在实际加载,并且 HTML 包含在页面 DOM 中的正确位置.

If css isn't being applied, then make sure that that your style sheets are actually being loaded, and that the HTML is being included in the proper place in your page's DOM.

这篇关于是否可以在 php 文件中包含 html 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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