Home >> PHP >> What is the difference between require and require_once in PHP

What is the difference between require and require_once in PHP

1-require() one file includes more times but require_once() one file includes only one times.

2-The require_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the require() statement, with the only difference being that if the code from a file has already been included, it will not be included again.

3-If file not found then show fatel error and stop execution of the script.


I have three files


function test(){
    echo "Hello";





When open file header.php you will get error because config.php already includes functions.php


Post Your Comment

Next Questions
What is difference between include_once and require_once
What is difference between include and require
What is meant by urlencode and urldecode
How To Get the Uploaded File Information
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars
How do you pass a variable by value
How do I find out the number of parameters passed into function
How To Protect Special Characters in Query String
What is the difference between GET and POST
What are the different types of errors
If conditional statement
If else conditional statement
If else / else if conditional statement
Switch conditional statement
For loop
While loop
Do while loop
Foreach loop
Arithmatic operators
Assignment operators
Increment / Decrement Operators
Comparision Operators
Logical operators
Array Operators

Copyright ©2022 coderraj.com. All Rights Reserved.