include and include_once in php code example

Example 1: php include once inside a function?

//yes this works 
  function derp(){include_once(yourfile.php);}

Example 2: require and require_once difference in php

As there is two different kind of require statements i.e. require and require_once
both are having same functionality of including file into the another.
  
Using require if the file is not misplaced or undefined then its stops the execution of the document.
<?php
 require 'requiredfile.php';
?>
  
And require_once is gets ignored if the file already imported with any other require or require_once.
<?php
 require_once 'require_oncefile.php';
?>

Tags:

Php Example