anouk
0
Q:

php require

// 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';
?>
5
// Require a file to be imported or quit if it can't be found
<?php
 require 'requiredfile.php';
?>
2
// 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';
?>
0
#Includes and requires Statements

#Includes and requires hlep you save time when it comes to changing small
 # aspects of otherwise identical pages. 
#Requires stop the script if there is something missing that is
 # require d in the place of where the inlcude statement is. 
#You can also have it be requiired once

#Example 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>Your web site</title>
 </head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <body>
    <ul>
        <li><a href="index.php">Home</a></li>
        <li><a href="about.php">About</a></li>
        <li><a href="contact.php">Contact</a></li>
    </ul>
    <h1>Home</h1>

 <?php 
 echo '<p>Your website -- under construction!</p>'
 ?> 

 <footer>
    <p>
        Your Website &copy; 2019
    </p>
 </footer>
 </body>
</html>
=================

becomes::

<?php include 'inc/header.php'; ?>

    <h1> Home</h1>

 <?php 
 echo '<p>Your Website -- under construction!</p>'
 ?> 
 <?php include 'inc/footer.php'; ?>
0

New to Communities?

Join the community