A copy book
RPG
PHP
Below within the directory includes is another
PHP page called head.php .... I would say that
inside of head.php would be all the header info
for the site....this way you could add this to
the top of each page and your site would remain
consistant. Just by modifying this one page
you could change the look of your entire site.
Some where within the head.php would most likely
be another include to a connection php page that
connects to the database. We will look at this
later.
require_once()--or-- include_once() makes sure that a
script(page) is only included once....
After the file is included once PHP will ignore and new
statements that include this file.
Lets test this here is the first PHP page.
here is header.php notice the "\" prior to the double quotes
this is required to escape the double quotes which indicate
start and end of the print string.... Also take not that
I just double quoted the html text ...I could have just
as easily keyed it in as straight HTML and moved the include
outside (above) the <? (start php) ..... image below is
what we get......
if you viewed source from the browser it would look like this
notice the include is gone and in its place is the contents of
the header.php page.
RPG
PHP Code:
À*
À* Copy book API data structures
À*
d/COPY QSYSINC/QRPGLESRC,QUSRUSAT
d/COPY QSYSINC/QRPGLESRC,QUSLMBR
d/COPY QSYSINC/QRPGLESRC,QUSGEN
Below within the directory includes is another
PHP page called head.php .... I would say that
inside of head.php would be all the header info
for the site....this way you could add this to
the top of each page and your site would remain
consistant. Just by modifying this one page
you could change the look of your entire site.
Some where within the head.php would most likely
be another include to a connection php page that
connects to the database. We will look at this
later.
PHP Code:
<?php include("includes/head.php");?>
script(page) is only included once....
After the file is included once PHP will ignore and new
statements that include this file.
PHP Code:
require_once('phpSniff.class.php');
Lets test this here is the first PHP page.
PHP Code:
<?
include("header.php");
// same comment id "//" as free RPG
// this will write the a header line 6 times
// because there are only 6 header sizes <h1>,<h2>,<h3>,<h4>,<h5>,<h6>
// notice the "." after the "This is header" this is for catnation of
// the test and the variable counter..(Variables are identified by the "$")
for ($counter = 6; $counter > 0 ; $counter--)
{
print "<h$counter>";
print "This is header" .$counter . "<br>" ;
print "</h$counter>";
}
?>
</body>
</html>
this is required to escape the double quotes which indicate
start and end of the print string.... Also take not that
I just double quoted the html text ...I could have just
as easily keyed it in as straight HTML and moved the include
outside (above) the <? (start php) ..... image below is
what we get......
PHP Code:
<?
print "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>Untitled</title>
</head>
\"some random text\"
<body>";
?>
notice the include is gone and in its place is the contents of
the header.php page.
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
"some random text"
<body><h6>This is header6<br></h6><h5>This is header5<br></h5>
<h4>This is header4<br></h4><h3>This is header3<br></h3>
<h2>This is header2<br></h2><h1>This is header1<br></h1>
</body>
</html>
Comment