Returning a variable from a function in php (return not working)

后端 未结 7 2053
旧时难觅i
旧时难觅i 2021-01-02 18:46

I\'m building an XML page inside of a function, and for some strange reason I don\'t get the whole thing spit out of the function. I\'ve tried

return $thisX         


        
7条回答
  •  佛祖请我去吃肉
    2021-01-02 19:12

    return $thisXml;
    }
    echo $thisXML;
    

    $thisXML; only exists in the scope of the function. Either make $thisXML; global (bad idea) or echo getThisXML() where getThisXML is the function that returns $thisXML;

提交回复
热议问题