PHP: variable not working inside of function?

后端 未结 5 928
滥情空心
滥情空心 2020-11-27 23:03
echo $path; //working
function createList($retval) {
    echo $path; //not working
    print \"
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 23:35

    If you want it to work, you should use global $path in the function, so it looks outside the function scope.

    Please note that global variables are sent from hell :).

提交回复
热议问题