- var_dump: documentation ( source)
- function_exists: documentation ( source)
- test1: documentation ( source)
<?php
function test1() {
// We have to check for existance because each call will try to define the function globally like including a file would.
if (!function_exists('test2')) {
function test2() {
echo 'there' . PHP_EOL;
}
}
echo 'here' . PHP_EOL;
}
echo "The internal method isn't defined yet: ";
var_dump(function_exists('test2'));
test1();
echo "Woops, function definitions don't get scoped by the function that define them. That's a feature but now we accidentally have a global function we might not have intended!: ";
var_dump(function_exists('test2'));
test2();