错误:当我在config.php上打印$ myconfig数组时,它会打印一个不同的值。仅关注[main_url],当在config.php上运行时其值会更改
myconfig.php
<?php
$base_url = $_POST['base_url'];
if($base_url == ""){
$url=((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". @$_SERVER['HTTP_HOST']."/football/responsive_filemanager";
}else{
$url=$base_url;
}
echo $base_url."</br>";
echo $url;
$myconfig=array(
'main_url'=>$url,
'upload_dir' => '/source/',
'current_path' => '../source/',
'thumbs_base_path' => '../thumbs/',
'multiple_selection' => false,
'multiple_selection_action_button' => false
);
//return $myconfig;
/*echo "<pre>";*/
//print_r($myconfig);
?>
config.php
<?php
include("../../myconfig.php");
print_r($myconfig);
exit();
?>
答案 0 :(得分:1)
我认为您的情况不对。您要在条件之前将值设置为$base_url
,因此它将始终在else语句中使用。因此,如果我不满意您的问题,则应将您的病情从$base_url == ""
更改为$base_url !== ""
if($base_url !== ""){
$url=((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http"). "://". @$_SERVER['HTTP_HOST']."/football/responsive_filemanager";
}
else{
$url=$base_url;
}