Is it possible to include an html file inside a php file(是否可以在 php 文件中包含 html 文件)
问题描述
我需要在 php 文件中包含一个 html 文件,我尝试在 php 文件中使用 include
和 require
,但没有应用 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 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以在 php 文件中包含 html 文件
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01