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 '我是函數(shù)foo喲,調一下我才會執(zhí)行定義函數(shù)bar的過程<br />'; function bar() { echo '在foo函數(shù)內(nèi)部有個函數(shù)叫bar函數(shù)<br />'; } } //現(xiàn)在還不能調用bar()函數(shù),因為它還不存在 bar(); foo(); //現(xiàn)在可以調用bar()函數(shù)了,因為foo()函數(shù)的執(zhí)行使得bar()函數(shù)變?yōu)橐讯x的函數(shù) 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