php include once code example

Example 1: php include once inside a function?

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

Example 2: php requuire once

require_once('var.php');

Example 3: 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';
?>

Example 4: require_once different on server

define('__ROOT__', dirname(dirname(__FILE__))); //call define untill you get to the root directory
require_once (__ROOT__."/Path/To/File.php"); //append __ROOT__ to the string

Tags:

Php Example