An external file
can be included anywhere in a Php file by using the Php include
function:-
include("xxx.php")
The include command simply takes all the text that exists in
the specified file and copies it into the file that uses the include
function.
When a file is included:-
The
included file inherits the functions, classes and variables above the line on which the
include occurs.
From that point forward, all functions, classes
and variables defined in the included file have the global scope.
An Include Example
Say we wanted to create a common menu file that all our pages
will use. A common practice for naming files that are to be included is
to use the ".inc" extension. Since we want to create a common menu
let's save it as "menu.inc".
Save the above file as "menu.inc".
Now create a new file, "index.php" in the same directory as "menu.inc".
Here we will take advantage of the include function
to add our common menu.
index.php
Code:
<?php
include("menu.inc"); ?> <p>
Web pages that uses a common menu just need to include
'menu.inc'
and all will have uniform menu.(save a lot of coding
works
too)
</p>
</body>
</html>
<?php
include("menu.inc"); ?> <p>
Web pages that uses a common menu just need to include
'menu.inc'
and all will have uniform menu.(save a lot of coding
works
too)
</p>
</body>
</html>
သင္၏ web page တိုင္း၏ ထိပ္တြင္၊ Home - About Us - Links - Contact Us ဆိုသည့္ link ပါေသာ ပံုတူပန္းတူ စါေၾကာင္း တခု ပါလာ သည္ကို ေတြ႔ရ ပါလိမ့္မည္။
All photograph,logos, articles, comments and trademarks -- etc in this site are property of their respective owners.All the rest (c) 2006 by PhpMyanmar.com.