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.

echo "This is a HEADER, And	 ";
echo "Today is ";
echo date("F d");
echo ", ";
echo date("Y");

Code 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.

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.

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.

4. The result?
Run body.php, it will display the picture as follows.

p.s. OHYA, save ALL the php file in the one – same folder. Ok, haapy cooding yah :D
Hal yang juga menarik:

Hak Cipta

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.

Related Articles:

Artikel terkait:


About the author

obviously, a girl. with sweet smile, off course. turning her 21 years trapped on Informatics departement and just started to having some crush with it lately. she uses wordpress. she loves php. she lo


Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

x( X-( B-) ;-) :wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :arrow: :D :?: :-| :-x :-o :-P :-D :-? :-)) :-) :-( :-& :) :( :!: 8-O 8-) 8) (Русский) (yahoo) (worship) (woot) (wave) (unsure) (tongue) (thinking) (tears) (taser) (smileydance) (sleeping) (sick) (scenic) (rofl) (rock) (party) (panic) (okok) (nottalking) (ninja) (music) (muscle) (muhaha) (money) (mmm) (lonely) (lol) (lmao) (idiot) (hungry) (highfive) (heart_beat) (heart) (headspin) (hassle) (haha) (gym) (griltongue) (goodluck) (girlkiss) (funkydance) (fish_hit) (eyeroll) (evilsmirk) (evil_grin) (drinking) (doh) (devil) (dance) (cry) (cozy) (coffee) (brokenheart) (bringit) (blush) (bigeyes) (beer) (banana_rock) (banana_ninja) (banana_cool) (applause) (annoyed) (angry) (K) (: