variable inside function is undefined code example Example: undefined variable inside function php $myId = 0; function run(){ global $myId; echo $myId; }