PHP Include


PHP Include:– PHP include keyword is used to import a php file into another file.This reduces time and rewriting of code instead of copy and paste strategy.So we recommend to use this include keyword to evaluate a specific php file which you need to include in your file.

If somebody deletes your file then use of include does not make any sense because echo statement will execute.So now we should use require keyword in place of include keyword.
Benefit of using require keyword over include is once require will find no existing file immediately it will kill echo statement.


PHP Include | Example

Below example shows how simplephp.php file’s content are accessed by Simple.php file.

Example of PHP Include//Simple.php

<?Php include ("simplephp.php");?>

Illustration of simplephp.php file.

<?Php
echo "hello php";
?>

Advertisements

Add Comment

📖 Read More