是否可以在 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.
相关文章