Internal function of php custom function
Internal function means that a function is declared inside the function.
Notes:
1. The internal function name cannot be an existing function name
2. Assume that an internal function is defined in function a, You cannot use function a twice.
Let’s look at the code below, you will learn it quickly:
<?php function foo() { echo '我是函數foo喲,調一下我才會執(zhí)行定義函數bar的過程<br />'; function bar() { echo '在foo函數內部有個函數叫bar函數<br />'; } } //現在還不能調用bar()函數,因為它還不存在 bar(); foo(); //現在可以調用bar()函數了,因為foo()函數的執(zhí)行使得bar()函數變?yōu)橐讯x的函數 bar(); //再調一次foo()看看是不是會報錯? foo(); ?>
You will find that a bar function is defined inside the foo() function above, which is the inner function number .
After careful observation and experimentation, you will draw the following conclusions:
1. Calling foo() twice will report an error
2. If you do not adjust the foo() function The bar function cannot be executed because bar is inside foo