PHP: variable not working inside of function?

后端 未结 5 925
滥情空心
滥情空心 2020-11-27 23:03
echo $path; //working
function createList($retval) {
    echo $path; //not working
    print \"
5条回答
  •  鱼传尺愫
    2020-11-27 23:23

    you must use the global modifier.

    echo $path;
    function createList($retval) {
        global path;
        echo $path; // works now :)
    

提交回复
热议问题