php加载页面问题与php include语句

时间:2018-06-09 05:20:21

标签: php include

我正在尝试使用 php include 来包含页面。

问题是我需要包含一个查询字符串,并且包含调用失败,即:

<?php include($urlroot.'/discounts/relatedcontent.php');?>

成功检索该页面,但是当我尝试

<?php include($urlroot.'/discounts/relatedcontent.php?tag=health');?>

php包含调用失败。

为什么我该怎么做呢?我需要将tag的值传递给$urlroot.'/discounts/relatedcontent.php'页面

1 个答案:

答案 0 :(得分:0)

include参数不能GET文件路径。因为include按原样获取文件名,并且无法处理?tag=health之类的任何规则。取而代之的是,您需要分离此脚本的一部分,在获取?tag=health时生成,并单独包含它。