All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

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 ❯