pTutorial

New way to learn Programming

How To Include File In Php

How To include file in php

PHP include or require function is used to include the file into another file before the server executes it. The PHP include and require function takes one argument (file_name) as string.

file_name: File name if file belongs to the same directory otherwise file name with absolute or relative path.

PHP include file example

<?php
echo "Main File Data
"; include "test.php"; ?>

Output

test.php

Main File Data
The quick brown fox jumps over the lazy dog.

Explanation

The file test.php contains "The quick brown fox jumps over the lazy dog."

The PHP include and require function is basically used for performing common task like navigation menu, configuration or connection with Database

See Also


QUOTES OF THE DAY

Knowledge itself is a power.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER