Table of Contents

PHP Includes

PHP Includes allow you to include one PHP file or HTML file inside of another. So let's make a file in which we can store all of our functions. Let's call that file functions,php. Then let's put a greeting function in there.


    function greeting(){
        return 'Welcome to Includes';


Now, if we want to use this function everywhere, we just have to add the functions.php file in all the other files using a function called include like this:

    include "functions.php";
<!DOCTYPE html>
    <title>My First PHP App</titile>
    <h1>Home Page</h1>

    <p><?php echo greeting(); ?></p>


The include function has to be at the top of our file, just like the session_start function.