所以我有一个页面标题是Magento模板的一部分;我希望它显示2个选项中的1个,具体取决于URL的内容。如果URL是选项1,显示标题1.如果URL为别的,显示标题2,这是我想出了,但它使我的页面崩溃:PHP如果URL等于这个,然后执行操作
<div class="page-title">
<h1><?php
$host = parse_url($domain, PHP_URL_HOST);
if($host == 'http://domain.com/customer/account/create/?student=1') {
echo $this->__('Create an account if you are a Post Graduate Endodontic Resident and receive our resident pricing. Please fill in all required fields. Thank you!')
}
else
{
echo $this->__('Create an Account')
}
?></h1>
</div>
人有什么想法?
编辑:所以它应该看起来像这样?
$host = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if($host == 'http://domain.com/customer/account/create/?student=1')
“使我的页面崩溃”是什么意思?你是否收到错误信息?更进一步:你在哪里定义了变量$ domain? – 2012-03-01 20:13:45
在页面的这部分加载之前的一切,然后停止。没有错误信息 – miles 2012-03-01 20:32:19
我从这个线程得到了$域:http://stackoverflow.com/questions/1122261/php-check-if-domain-equals-value-then-perform-action – miles 2012-03-01 20:33:13