Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP INCLUDES FOR MODULARIZATION CIT 230 – WEB FRONT-END DEVELOPMENT.

Similar presentations


Presentation on theme: "PHP INCLUDES FOR MODULARIZATION CIT 230 – WEB FRONT-END DEVELOPMENT."— Presentation transcript:

1 PHP INCLUDES FOR MODULARIZATION CIT 230 – WEB FRONT-END DEVELOPMENT

2 WHAT IS MODULARIZATION? Modularization is the idea of separating a website into modules. A module can be a section that repeats itself across a website. Example: Website headers and website footers can be modules. They are usually the same throughout an entire website. Website Body Header Footer

3 WHY USE MODULARIZATION? Imagine a 250-page website that needs an update in the footer. With html only, you’d have to edit every single page, which would be a very tedious and error-prone task (even with copy/paste). It saves time, money, and is easy to maintain. It can be done with a PHP include.

4 WHAT IS A PHP INCLUDE? PHP is a scripting language used for web development. include is a command in the PHP language. It tells PHP to “include” a file. This is how a website can be modularized.

5 SYNTAX OF PHP INCLUDE STATEMENT The syntax is composed of 5 elements 1. The opening PHP tag: <?php 2. The include command itself: include 3. The file path and name in quotes: ’/modules/footer.php’ 4. A semi-colon to end the PHP statement: ; 5. The closing PHP tag: ?> The result:

6 WHERE TO INCLUDE THIS PHP INCLUDE? The include statement can go right in the html code. This is part of the file path. It tells the server to start at the root. Without this segment, the path would look something like this instead:

7 FILE STRUCTURE With PHP include, you only need 1 file per module. A suggestion is to keep them organized into a module folder. Example: footer.php can be designated to be the only footer file across the entire website.

8 WHAT IS INSIDE THE MODULE FILE? The actual code that will be inserted! It is not an html file, so,, etc. are not needed. Think of it as a snippet of code that is going to be inserted into a real html file (the one with the php include).

9 EXAMPLE: BEFORE PHP INCLUDE

10 EXAMPLE: AFTER PHP INCLUDE

11 WHAT ABOUT THE PAGE SOURCE? Assuming the web host supports PHP, visitors will not see the php code in the page source. PHP leaves no evidence!

12 RESOURCES From PHP itself: http://php.net/manual/en/function.include.php YouTube video on using PHP includes to modularize a website: https://www.youtube.com/watch?v=R7k1K7UMs50 THANK YOU


Download ppt "PHP INCLUDES FOR MODULARIZATION CIT 230 – WEB FRONT-END DEVELOPMENT."

Similar presentations


Ads by Google