Function within another function in PHP

By: Martyniuk Vasyl  

If you define function within another function, it can be accessed directly, but after calling parent function.
For example:
<?php
function a () {
  function b() {
    echo "I am b.";
  }
  echo "I am a.<br/>";
}
//b(); Fatal error: Call to undefined function b() in E:\..\func.php on line 8
a(); // Print I am a.
b(); // Print I am b.
?>



Archived Comments


Most Viewed Articles (in PHP )

Latest Articles (in PHP)

Comment on this tutorial