Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在内爆PHP中使用required_Php - Fatal编程技术网

如何在内爆PHP中使用required

如何在内爆PHP中使用required,php,Php,我现在有个问题。它是关于在PHP的内爆元素中使用required的 当前的项目是使用$\u GET参数组装样式化文件。因此,我不需要多个标记,只需要一个 这里有一个例子: 现在包括minify.php文件。为了包含style.php文件,我创建了一个explode/infrade元素。有了它,新的URL如下所示: 但是现在我有一个500服务器错误,因为我不知道如何将所需元素包含到内爆元素中 现在代码是: <!-- language: lang-php --> <?ph

我现在有个问题。它是关于在PHP的内爆元素中使用required的

当前的项目是使用$\u GET参数组装样式化文件。因此,我不需要多个
标记,只需要一个

这里有一个例子:

现在包括minify.php文件。为了包含style.php文件,我创建了一个explode/infrade元素。有了它,新的URL如下所示: 但是现在我有一个500服务器错误,因为我不知道如何将所需元素包含到内爆元素中

现在代码是:

<!-- language: lang-php -->
    <?php
    header("Content-type: text/css");
    $sheet = $_GET["sheet"];
    $styles = explode("|", $sheet );
    $value = implode("", $styles);
    require ('assets/' . $value . '.php');
    ?>
我希望你能帮助我

多谢各位

其他:

  • .htaccess文件的代码:

    重新编写引擎打开
    重写条件%{REQUEST_URI}!。php$[NC]
    重写规则^(.*)$$1.php[QSA]

  • bucketfront子域样式表帮助器上的所有文件:

.htaccess
css.php
/assets/minify.php

/assets/style.php

您应该将所有文件作为一个文件包含在内(在HTTP协议中,一个请求不能发送超过一个回复)。在代码中添加注释

<?php
header("Content-type: text/css");
$sheet = $_GET["sheet"];
$styles = explode("|", $sheet );
// include each file.
// If your styles are simple stylesheets (no php parsing required) 
// try using readfile instead of include
foreach ($styles as $value){
    include ('assets/' . $value . '.php');
    // readfile method
    // readfile ('assets/' . $value . '.php');

}

这是我最后使用的代码:

<?php
header("Content-type: text/css");
$sheet = $_GET["sheet"];
$styles = explode("|", $sheet );
$output = $styles; 
foreach ($output as $value) {
require ('assets/' . $value . '.php');
}
?>


我像班西说的那样绕了一圈。来源:

你的问题不清楚。为什么要使用内爆?您应该循环使用从explode获得的样式,并在每个样式上使用
require
,我想我可以像以前使用
span
标记一样包含所需的元素。但是谢谢你的回复。你的意思是像这样从explode循环样式吗?我不知道从哪里生成
…css?sheet=style | minify
请求。如果它来自html(web浏览器),则不能为单个请求发送2个文件。您可以将两个文件连接到一个文件中,并将答复作为一个文件发送。请求是从生成的。我想我可以像谷歌一样使用谷歌字体API。他们也使用这样的技术。示例:我认为将两个文件都包含到一个文件中已经是一种连接。@非常感谢您解决了我的问题。我使用W3schools上的循环函数来包含每个文件。谢谢@bansi。我将使用这个版本。如果您不打算在样式表中使用php代码,请尝试使用
readfile
,这样效率更高,因为它不需要在文件上运行php解析器的开销<代码>读取文件('assets/'.$value.'.php')<?php header("Content-type: text/css"); $sheet = $_GET["sheet"]; $styles = explode("|", $sheet ); $output = $styles; foreach ($output as $value) { require ('assets/' . $value . '.php'); } ?>