Modular structure of page
Pages of sites usually are under construction by a modular principle - for example,
Above each page there is a name of a site with a trade mark,
Below - a sign on protection of copyrights, at the left - the navigating panel, in the middle - actually the maintenance{contents} of web-page (clause{article}, the review, etc.).
Thus on all pages all parts, except for the maintenance{contents}, are identical (i.e. an identical cap, the panel of navigation t. Item).
To do{make} such pages separately is a bad form. Imagine, that you have added one more section on a site and
You needed to change the panel of navigation on each page of a site. Even it is terrible to think, if them some hundreds.
Therefore we now also shall see, as it is necessary to build page by a modular principle - i.e. each part of page will be
It is stored{kept} in a separate file - top of page with a trade mark in one, navigation in the friend, etc.
Now, if you, for example, should change navigation it will make only in one file enough.
Each our page will consist of four parts: the top part with the name of a site,
The bottom part with the information on copyrights, the left part with navigation and an information right part.
Each page will "be going to" from 5 files - on one for each part and plus still a file,
Uniting all four part. Transfer of all necessary files:
xxxxx.php - a file with the information. This file will be typed{collected} also by the visitor in a line of a browser.
Includes a file main.inc. The name of this file will be the for each page of a site.
In our example of such pages will be three: 1.php, 2.php and 3.php.
main.inc - a file specifying the general{common} arrangement of elements on web-page.
Includes all other files, except for xxxxx.php.
header.inc - a file the top part of page (with the name of a site).
footer.inc - a file the bottom part of page (with copyrights).
nav.inc - a file with navigation on a site (raspologaetsja in the left part of each page).
Let's result a code for each file.
File 1.php (it is one of information files xxxxx.php):
<?
$content = "
<h2> Furniture </h2>
<p> Welcome to our site!... </p>
";
include ("main.inc");
?>
As you see, here we get{start} a variable $content in which we write down informafionnoe
The maintenance{contents} of our page. In this variable it is possible to write down including tegi (that we, as a matter of fact, and we do{make}).
Except for that in this page it is included by means of the operator include a file main.inc. include we do{make}
After the announcement of a variable $content as in a file main.inc this variable will be used.
Pay also attention that 1.php we conclude all contents of a file in tegi php.
2.php and 3.php we do{make} files absolutely similarly:
<?
$content = "
<h2> Tables </h2>
<p> Our firm is glad to offer you the following tables... </p>
";
include ("main.inc");
?>
<?
$content = "
<h2> Cases </h2>
<p> We are glad to offer you the following models of cases... </p>
";
include ("main.inc");
?>
File main.inc:
<html>
<head>
<title> </title>
</head>
<body>
<table cellspacing = "2" cellpadding = "2" border = "0" width=100 %>
<tr>
<td colspan = "2">
<? include ("header.inc");?>
</td>
<tr>
<tr>
<td width = " 20 % "> </td>
<td> </td>
</tr>
<tr>
<td colspan = "2" align=right>
<? include ("footer.inc");?>
</td>
</tr>
<table>
</body>
</html>
Here we, as a matter of fact, set a breadboard model for our html-page - we set tegi <head>, <body> and others,
We set an arrangement of elements on page by means of the table. In the first cell of the table we insert
File of heading with the name of a site:
...
<td colspan = "2">
<? include ("header.inc");?>
</td>
...
In last - a file with copyrights:
...
<td colspan = "2" align=right>
<? include ("footer.inc");?>
</td>
...
An average number{line} of the table will consist of two cells in which we insert a file with navigation and value of a variable $content:
<tr>
<td width = " 20 % "> <? include ("nav.inc");?> </td>
<td> <? print $content?> </td>
</tr>
We pass to files header.inc, footer.inc and nav.inc.
File header.inc:
<h1> the Furniture site </h1>
File footer.inc:
(c) copywrite alexeev igor, 2002-2003
File nav.inc:
<a href = "1.php"> Main </a> <br>
<a href = "2.php"> Tables </a> <br>
<href = "3.php"> Cases </a>
These files are identical to all pages of a site. In them we describe top and nizhniju parts for everyone
web-pages of a site, and also the panel of navigation.
Everything, staranicy are created! Place them in one catalogue on your web-server, and through a browser
See{Overlook} pages 1.php, 2.php and 3.php. At the left on each page there will be a panel of navigation, on the right-
Substantial part of page, above and below - the name of a site and the information on copyrights.
If you see{overlook} through a browser a html-code for required pages 1.php, 2.php and 3.php,
That of any code php, naturally, will not see - that will be only the html-code generated by the web-server.
The converter kirillichnogo the text in Unicode on PHP
In clause{article} we shall tell to you as cyrillics to convert in unicode.
In php there are no standard means of the coding in unicode for cyrillics, therefore insert this function to itself in a code or through include () and is caused so:
$cyr = " the Life of remarkable people "
$unicode=cyr_code ($cyr);
?>
All nekirilichnye signs will stay untouched.
// Code conversion win-> unicode
function cyr_code ($in_text) {
$output = "";
$other [1025] = "¬";
$other [1105] = "±";
$other [1028] = "=";
$other [1108] = "?";
$other [1030] = "i";
$other [1110] = "i";
$other [1031] = "¶";
$other [1111] = "§";
for ($i=0; $i
if (ord ($in_text {$i})> 191) {
$output. = " and * ". (ord ($in_text {$i}) +848). ";";
} else {
if (array_search ($in_text {$i}, $other) === false) {
$output. = $ in_text {$i};
} else {
$output. = " and * ".array_search ($in_text {$i}, $other). ";";
}
}
}
return $output;
}

|