require() function in php || PHP Functions

require() function in php


require() function works same as include() function works. By using this function you can get the values/data of the that file which is mentioned in require() function.

The difference is only that if file path is not properly mentioned then this require() function throws a fatal error and halts/stops the execution of the file. 

Mostly, this function is required when you use all the data of a file or section at many places in other files.

How to use: require() function in PHP

=> Remember that this function can be used as a statement. Like below:-

require "filename";

=> It is not necessary to use ()braces with the require statement. 

=> Both work same.

require "test1.php";

require "testing_file.php";

echo "<p>hi</p>";


echo "<p>hi</p>";

Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments