你会认为我应该在Google上找到这个,但我不能。
的config.ini
[ENVIRONMENT]
env = prod
js_path = js/
css_path = css/
;host= www.xxxxxxxx.com
host=http://localhost:8080/home
test = 0
我需要在这里读取主机的值:
<?php
header('Location: ?????????????????');
echo 'Thank you for contacting us. We will be in touch with you very soon.';
}
?>
有谁知道?
答案 0 :(得分:1)
这很简单。使用内置函数parse_ini_file()
:
$ini_array = parse_ini_file('../containing-folder/config.ini');
$host = $ini_array['host'];
而且,要重定向用户,您可以执行以下操作:
if (isset($host) && filter_var($host, FILTER_VALIDATE_URL)) {
echo 'Thank you for contacting us. We will be in touch with you very soon.';
header("Location: $host");
exit();
}
这也将确保$host
是有效的网址。