Last active
February 15, 2019 19:39
-
-
Save AllenEllis/fe8ee666b0868be66a1bb7144c19dfa2 to your computer and use it in GitHub Desktop.
Revisions
-
AllenEllis revised this gist
Feb 15, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ Contents of `index.html`: <p>Contact info here</p> </footer> </body> </html> ``` To seperate this out, we should consider which code we want to duplicate across every page, and move those over to separate files. We can make a new directory to hold those. @@ -67,4 +67,5 @@ New file: `templates/footer.php` <p>Contact info here</p> </footer> </body> </html> ``` -
AllenEllis revised this gist
Feb 15, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ For PHP code to execute, two things have to happen: 1. The filename needs to end in `.php` 2. The PHP code needs to exist between an opening PHP tag `<?php` and, optionally, a closing PHP tag `?>` ## Original code Contents of `index.html`: ```html @@ -37,7 +37,7 @@ templates/ - footer.php ``` ## Revised code The contents of `index.php` change to: ```php <?php -
AllenEllis created this gist
Feb 15, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ # PHP: introduction to `include();` For PHP code to execute, two things have to happen: 1. The filename needs to end in `.php` 2. The PHP code needs to exist between an opening PHP tag `<?php` and, optionally, a closing PHP tag `?>` ## Code before Contents of `index.html`: ```html <html> <head> <!-- header content here --> </head> <body> <h1>Page name</h1> <p>Page content</p> <footer> <p>Contact info here</p> </footer> </body> ``` To seperate this out, we should consider which code we want to duplicate across every page, and move those over to separate files. We can make a new directory to hold those. ##### Before: directory structure ``` index.html ``` ##### After: directory structure ``` index.php templates/ - header.php - footer.php ``` ## Code after The contents of `index.php` change to: ```php <?php include("templates/header.php"); ?> <h1>Page name</h1> <p>Page content</p> <?php include("templates/footer.php"); ?> ``` New file: `templates/header.php` ```php <html> <head> <!-- header content here --> </head> <body> ``` New file: `templates/footer.php` ```php <footer> <p>Contact info here</p> </footer> </body> ```