【发布时间】:2011-07-17 15:39:26
【问题描述】:
这是名为“VariablesFunctions.php”的包含文件:
$currWebPage = '';
function getPageUrl( )
{
global $currWebPage;
if( $_SERVER['HTTPS'] == 'on' ) $currWebPage .= 's';
$currWebPage .= '://';
if( $_SERVER["SERVER_PORT"] != "80" )
$currWebPage .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else $currWebPage .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
这里是调用它的文件(index.php):
<?php include( 'VariablesFunctions.php' );
getPageUrl( );
echo $currWebPage;
?>
两个文件都保存在同一个目录下,当启动 index.php 文件时,浏览器显示未定义函数(上面 index.php 文件中的第 2 行),为什么?
【问题讨论】:
-
浏览器没有说明
file not found吗? -
不。相反,它会复制调用它的 VariablesFunctions.php 的全部内容,这是为什么呢?
-
因为您使用的不是您在此处发布的代码