Library
The use of libraries is extremely useful, it allows us to group several functions and variables in the same file so that we are able to include a library in different pages and make these functions easily available.
<!-- PHP Tutorial WebEstilo.com -->
<?php
function CabeceraPagina()
{
?>
<FONT SIZE="+1">The header.</FONT><BR>
<hr>
<?
}
function PiePagina()
{
?>
<hr>
<FONT SIZE="-1">The footer</FONT><BR>
Author: Joaquin Gracia
<?
}
?>
Now we are going to create 2 pages that will use the previously defined library to get the two pages to have the same header and footer.
The statement used to include a library in our page is include("name of library")
<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php include("libreria01.phtml") ?>
<?php CabeceraPagina(); ?>
Page 1
<BR><BR><BR><BR><BR>
Content blalbl blalb alb<BR><BR>
that...<BR><BR>
end<BR><BR>
<?php PiePagina(); ?>
</body>
</html>
<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php include("libreria01.phtml") ?>
<?php CabeceraPagina(); ?>
Another page<BR><BR>
<?php PiePagina(); ?>
</body>
</html>