include_once in php code example

Example 1: include and require in php

// Include a file, if it can't be found: continue.
<?php
include 'mainfile.php';
?>
  
// Alternatively: Require a file to be imported or quit if it can't be found
<?php
 require 'requiredfile.php';
?>

Example 2: php include once inside a function?

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

Example 3: php requuire once

require_once('var.php');

Example 4: require_once php

// Require_once is ignored if the required file has already been added by any of the include statements.
<?php
 require_once 'require_oncefile.php';
?>

Tags:

Php Example