【发布时间】:2012-03-01 20:01:31
【问题描述】:
所以我有一个页面标题,它是 Magento 模板的一部分;我希望它显示 2 个选项中的 1 个,具体取决于 URL 是什么。如果 URL 是选项 1,则显示标题 1。如果 URL 是其他内容,则显示标题 2。这是我想出的,但它使我的页面崩溃:
<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?
-
这部分页面加载之前的所有内容,然后停止。没有错误信息
-
我从这个帖子获得了 $domain:stackoverflow.com/questions/1122261/…
标签: php if-statement