因为它没有在函数中定义。
有几种方法可以解决此问题:
1)使用亚历克斯所说的话,告诉函数它是一个全局变量:
echo $path; // workingfunction createList($retval) { global $path; echo $path; // working2)将其定义为常量:
define(PATH, "/my/test/path"); // You can put this in an include file as well.echo PATH; // workingfunction createList($retval) { echo PATH; // working3)如果特定于该函数,则将其传递给该函数:
echo $path; // workingfunction createList($retval, $path) { echo $path; // working根据功能的实际工作原理,其中之一会起作用。



