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