PHP - 如果域

发布于 2024-11-17 20:37:58 字数 226 浏览 0 评论 0原文

我在多域 1 模板设置上有以下代码:

<?php  $host = parse_url($domain, PHP_URL_HOST);
if($host == 'www.justdoors.co') {
echo "action goes here";
} ?>

由于某种原因,当我在 www.justdoors.co 域上时,它没有执行该操作,我缺少什么?

I have the following piece of coding on a multi-domain 1 template setup:

<?php  $host = parse_url($domain, PHP_URL_HOST);
if($host == 'www.justdoors.co') {
echo "action goes here";
} ?>

For some reason it's not carrying out the action when I'm on the www.justdoors.co domain, what am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傾城如夢未必闌珊 2024-11-24 20:37:58

使用 $_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 
 }

Use $_SERVER['SERVER_NAME'] or $_SERVER['HTTP_HOST'] variable

 $host = $_SERVER['HTTP_HOST']; 
 if($host == "www.justdoors.co" or $host == "justdoors.co") {
     //do anything you want to do 
 }
枕花眠 2024-11-24 20:37:58

我之前已经在我的服务器上成功使用过这个。

<?php if ( $_SERVER['SERVER_NAME'] == 'www.domain.com' ) { echo ''; } ?>

I have used this successfully on my server before.

<?php if ( $_SERVER['SERVER_NAME'] == 'www.domain.com' ) { echo ''; } ?>
§普罗旺斯的薰衣草 2024-11-24 20:37:58

我已经尝试过了,它工作得很好..

<?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;
}
?>

I have tried this and it's working perfectly ..

<?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;
}
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文