PHP Tutorial : Including files with require/include

Welcome,

I’ve just created a brand new category here name basic php and I got my chance to explain you guys how you may include external php files into another ones. There are ways and ways but I will explain only two of them, the most popular ones. The first one, is called include() a php function which you may use it for simple things. I wouldn’t use it for a database connection, for that, exists the require_once() function. The difference between those two php functions is that include() function will give you a warning if the remote include file doesn’t exists. On the other side , the require_once() php function will stop parsing the script if the remote file wont be finded.

The usage is very basic like that

1
2
3
4
5
6
7
8
9
<?php

include('filename.php');

//or

require_once('mydb.php');

?>
This entry was posted in Basic PHP and tagged , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>