PHP /获取当前URL +条件

时间:2013-02-11 05:06:32

标签: php

我不擅长php,但我想检测用户是否在网站的家中,如;

<?php
if (current path = http://website.com/ || website.com)
{?>

<div>We are in home</div>

<?php } else { ?>

<div>do something</div>
<?php } ?>

有人帮助我,谢谢

1 个答案:

答案 0 :(得分:5)

 $pageName = $_SERVER['PHP_SELF'];

 if($pageName == 'http://website.com'){
       echo '<div>We are in home</div>';
 } else { do something };