Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.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/7/css/42.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/9/opencv/3.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 在源代码中创建新行_Php_Css - Fatal编程技术网

Php 在源代码中创建新行

Php 在源代码中创建新行,php,css,Php,Css,我正在尝试动态加载CSS、JS和其他部分,但我遇到了一点麻烦。这不会对功能产生太大影响,因为我不喜欢查看源代码时看到的内容。 我的来源,当我看到它是这样的 你可以看到它就在那里。这是可行的,但男人就是这么乱! 我希望它在每个源代码之间有一条新行,我用来提取这些信息的代码是 function LoadTheme($argument) { switch($argument) { case "active": $theme = Frontend; br

我正在尝试动态加载CSS、JS和其他部分,但我遇到了一点麻烦。这不会对功能产生太大影响,因为我不喜欢查看源代码时看到的内容。 我的来源,当我看到它是这样的

你可以看到它就在那里。这是可行的,但男人就是这么乱! 我希望它在每个源代码之间有一条新行,我用来提取这些信息的代码是

function LoadTheme($argument) {
    switch($argument) {
        case "active":
            $theme = Frontend; break;
        default: $theme = $argument; break;
    }
    $configFile = "config.json";
    $configPath = frontend.'/'.$theme.'/'.$configFile;
    $themePath = frontend.'/'.$theme.'/';
    if(file_exists($configPath)) {
        LoadThemeIncludes($configPath,$themePath);
    }
    else {
        echo "Fatal Error. No theme Configuration Found";
    }
}
function LoadThemeIncludes($configPath,$themePath) {
    $string = file_get_contents($configPath);
    $json_a = json_decode($string, true);
    $stylesheets = $themePath.''.$json_a['includes']['css'].'/*.css';
    foreach(glob($stylesheets) as $stylesheet) {
        echo '<link rel="stylesheet" type="text/css" href="'.ConvertURL($stylesheet).'" media="screen" />';

    }
}
function ConvertURL($path) {
    $cv = str_replace(public_p, $_SERVER['HTTP_HOST'], $path);
    return $cv;
}
我想做到的是,当用户查看源代码时,他们不仅仅看到它像图片一样包装,而是 源在每行之后都会有一行新行。

要打印新行:

echo PHP_EOL;

在PHP中,可以使用
\r\n
呼出新行

因此,您必须在函数
中更改for each循环加载meincludes

foreach(glob($stylesheets) as $stylesheet) {
    echo '<link rel="stylesheet" type="text/css" href="'.ConvertURL($stylesheet).'" media="screen" />' . "\r\n";
}
foreach(glob($stylesheet)作为$stylesheet){
回显“”。“\r\n”;
}

或者像其他答案中提到的那样,您可以使用常量
PHP\u EOL

只需在echo
echo“”中添加新行即可。PHP_EOL过去一个半小时的谷歌搜索,就这样做了。。。。谢谢。我想您需要对
\r\n
使用双引号才能工作
foreach(glob($stylesheets) as $stylesheet) {
    echo '<link rel="stylesheet" type="text/css" href="'.ConvertURL($stylesheet).'" media="screen" />' . "\r\n";
}