require once function

As your site grows, you may find yourself redundantly including certain files. Although this might not always be a problem, sometimes you will not want modified variables in the included file to be overwritten by a later inclusion of the same file. Another problem that arises is the clashing of function names should they exist in the inclusion file. You can solve these problems with the require_once() function.

require once syntax :

<?php
 require_once (filename);
?>

The require_once() function ensures that the inclusion file is included only once in your script. After require_once() is encountered, any subsequent attempts to include the same file will be ignored.

Other than the verification procedure of require_once(), all other aspects of the function are the same as for require().

require once example :


<?php
 require_once "require /left.inc.php";
  /* the script continues here */
?>

left.inc.php

left.inc.php is a File.





Content