简体   繁体   English

使用PHP在CSS样式表中包含HTML

[英]Using PHP to include HTML with CSS stylesheet

Related: https://stackoverflow.com/a/8198408/406110 相关: https : //stackoverflow.com/a/8198408/406110

login.php file: (despite being a php file, it doesn't have php code, only html) login.php文件:( 尽管是php文件,但没有php代码,只有html)

<html>
<head>
    ...
    <script src="/js/less.js" type="text/javascript"></script>
    <link 
        href="login.less" 
        rel="stylesheet/less" 
        type="text/css">
</head>
<body>...</body>
</html>

load.php file: load.php文件:

<?php print file_get_contents('login.php'); ?>

I would like to load the content of the file login.php using load.php . 我想使用load.php加载login.php文件的内容。 It is possible, HTML is being write correctly, but CSS/LESS is not loading: 可能是HTML编写正确,但是CSS / LESS没有加载:

login.less file: login.less文件:

body { background-color: red; }

Why? 为什么?

Edit 1 编辑1

I am using "Client-side Usage" to run LESS files. 我正在使用“客户端用法”来运行LESS文件。

Seems it is a LESS problem. 似乎是较少的问题。 But why isn't it working? 但是为什么它不起作用?

Problem solved: 问题解决了:

Somehow, LESS was not being compiled, I changed from Client-side Usage to a compiling approach. 不知何故,LESS没有被编译,我从客户端用法改为了编译方法。 Thank you everybody! 谢谢大家!

I think what you really want is just an include: 我认为您真正想要的只是一个包括:

<?php include('login.php'); ?>

This just includes the contents of the other file (in this case login.php) into your current file. 这只是将另一个文件(在本例中为login.php)的内容包含到当前文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM