Discussion Board : Using PHP Include code to make listings more efficiently.
Requirements: Webserver Package, already installed.
INCLUDE, generally used for the php code that will be frequently used, means that the code which will often be written repeatedly in building applications or any coding in PHP.
Why using Include ?
1. It would be very inefficient if we must write the same code repeatedly.
2. If it were the case there are parts of the code that must be changed, then, once again, be very inefficient if you need to change the wrong one by one.
And once again, this will be very redundant and time-consuming and lead to potential human error. By using include, the problem – this problem can be overcome.
Does it Include?
PHP file include is inserted in another PHP file, generally include contain information that will repeatedly be used in other code. For example, if you want to build the site navigation to be displayed in every page of your site, then you simply write the code navigation is in one file for later to include it in every page of the site.
Case Studies : Using Include for Header and Footer.
1. Create a header.
Suppose we want to display today’s date as a header. Type the following script.
<?php echo "This is a HEADER, And "; echo "Today is "; echo date("F d"); echo ", "; echo date("Y"); ?>
date The above will display today’s date. Save the script above with the name of header.php.
2. Creating a footer.
For example we will display the copyright as a footer to our site. Type the script below.
<?php echo "Copyright by itx.web.id"; ?>
Save the script above with the name footer.php
3. Placing the header and footer in the page.
Type the following script.
<?php include "header.php"; echo "<h1> This is the BODY of site !</h1>"; include "footer.php"; ?>
Suppose we want to put the header at the top page, then the code to header.php must diinclude weight on the code as well (on body). Similarly for the footers, because it is located at the bottom of the page, then the code is also placed at the bottom footer.php code.
Semua skrip dan teknik dalam artikel di itx.web.id boleh digunakan sebagaimana kehendakmu tanpa perlu mencantumkan sumber. Kamu tidak boleh mengkopi seluruh artikel, dalam Bahasa Indonesia ataupun diterjemahkan ke dalam bahasa lain.