Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

PHP Include And Require

PHP Include And Require

PHP Include is used to add other php file into another php file before the server executes it.


There are two ways to insert php file into another

  • With include()
  • With require()


With include()

With include() function you can copy all the content of a php file and copy it to another file.If unfotunately the copy cannot done it genrates warning but the script will continue execution.


/*This is demo.php file*/

<?php
This is come content Here
?>


/*This is hello.php file*/

<html>
<body>

<?php include("demo.php"); ?>
<p>This is include PHP file example</p>
	
</body>
</html>




With require()

With require() function you can copy all the content of a php file and copy it to another file like include function but if the copy cannot done it genrates error and terminate the script.


/*This is demo.php file*/

<?php
This is come content Here
?>


/*This is hello.php file*/

<html>
<body>

<?php require("demo.php"); ?>
<p>This is include PHP file example</p>

</body>
</html>

PrevNext

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH

Check Out SEMRUSH