我有以下的片上多域1個模板設置編碼的:當我PHP - 如果域
<?php $host = parse_url($domain, PHP_URL_HOST);
if($host == 'www.justdoors.co') {
echo "action goes here";
} ?>
出於某種原因,它不進行動作的www.justdoors.co域名,我錯過了什麼?
我有以下的片上多域1個模板設置編碼的:當我PHP - 如果域
<?php $host = parse_url($domain, PHP_URL_HOST);
if($host == 'www.justdoors.co') {
echo "action goes here";
} ?>
出於某種原因,它不進行動作的www.justdoors.co域名,我錯過了什麼?
使用$_SERVER['SERVER_NAME']
或$_SERVER['HTTP_HOST']
可變
$host = $_SERVER['HTTP_HOST'];
if($host == "www.justdoors.co" or $host == "justdoors.co") {
//do anything you want to do
}
我以前在我的服務器上成功地使用了它。
<?php if ($_SERVER['SERVER_NAME'] == 'www.domain.com') { echo ''; } ?>
我曾經嘗試這樣做,它的工作完美..
<?php
function conn()
{
$ora_con=0;
//development connection building
if ($_SERVER['SERVER_NAME'] == 'xyz.com')
{$username='scott';
$password = 'tiger';
$ora_conn_string = 'conn_name:port_no/db_name';
//echo "<br>development connection building";
$ora_con = oci_connect($username,$password,$ora_conn_string);
//echo '<br>dev connection build<br>';
}
//Production connection building
elseif ($_SERVER['SERVER_NAME'] == 'abc.net')
{$username='prod_scott';
$password = 'prod_tiger';
$ora_conn_string = 'conn_name:port_no/db_name';
//echo "<br>Production connection building";
$ora_con = oci_connect($username,$password,$ora_conn_string);
//echo '<br>Prod connection build<br>';
}
return $ora_con;
}
?>
什麼是'$ domain'的價值? –
當你在這個域時'$ host'的值是多少? – Jon