Locked lesson.
About this lesson
Similar to "Include", but used for a slightly different reason.
Exercise files
Download this lesson’s related exercise files.
Require Function.docx59 KB Require Function - Solution.docx
59.1 KB
Quick reference
Require Function
The require function is another way to add things from other files.
When to use
You would use the require function when an error message that crashes your whole program is needed.
Instructions
Require is another way to add things from one file to another.
require 'filename.php';
The main difference between it and "include" is that if there's a problem, you'll get an error message and then the entire program will stop.
Hints & tips
- require 'filename.php'
- If there's an error while using require, your whole program will stop.
Lesson notes are only available for subscribers.