require file 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: require in php

// Require a file to be imported or quit if it can't be found
<?php
 require 'requiredfile.php';
?>

Example 3: php require

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

Tags:

Php Example