Aims:
phpinfo
,
date
date
is a function that gets the current date/time from the server
and formats itnews.php
: illustrates date
function<body> <div id="banner"> <?php echo date('D F j Y, h:i:s a'); ?> </div> ... </body> </html>
footer.html
:
<div id="footer">
<p>
Comments about this Web site:
<a href="mailto:d.bridge@cs.ucc.ie">Derek Bridge</a>
</p>
<p>
© 2007 Department of Computer Science.
</p>
</div>
include
command to incorporate
footer.html
:
<body>
...
<?php
include 'footer.html';
?>
</body>
</html>
include
include
loads a file
.html
.inc
require
, include_once
, require_once
$qty
, $QTY
and
$Qty
are differentanswer.php
: a script that uses a variable<body> <?php $answer = 42; ?> <p> What is the answer to Life, the Universe, and Everything? <?php echo $answer; ?> </p> </body> </html>
$myAge = 19;
$myTwinsAge = $myAge;
$my_sisters_age = $myAge + 2;
$minsPerHour = 60;
$temperature = 15.6;
$pi = 0.0314E2;
true
or false
)
$php_is_good = true;
&groovy_is_good = false;
$moduleCode = 'CS1102';
$moduleName = "Internet Computing";
int price = 2; $price = 2; price = price + 3; $price = $price + 3; price = price + 0.5; $price = $price + 0.5;
sections.html
...<body> <h1>A History of Lobotomies</h1> <h2>Section 1: Introduction</h2> <p>Blah, blah, blah.</p> <h2>Section 2: 19th Century Lobotomies</h2> <p>Blah, blah, blah.</p> ... </body> </html>
sections.php
<body> <h1>A History of Lobotomies</h1> <?php $sectionNum = 0; ?> <?php $sectionNum = $sectionNum + 1; ?> <h2>Section <?php echo $sectionNum; ?>: Introduction</h2> <p>Blah, blah, blah.</p> <?php $sectionNum = $sectionNum + 1; ?> <h2>Section <?php echo $sectionNum; ?>: 19th Century Lobotomies</h2> <p>Blah, blah, blah.</p> ... </body> </html>