Escolar Documentos
Profissional Documentos
Cultura Documentos
and Time
2
Prepared by: Jerick Carlo Almeda *
Similarly, dates and times are so much a
part of everyday life that it becomes easy to
use them without thinking. However,
because the quirks of the Gregorian
calendar can be difficult to work with, PHP
provides powerful tools that make date
manipulation an easy task.
<?php if (strlen($membership) == 4) {
echo "<p>Thank you!</p>";
} else { echo "<p>Your membership number must have
4 digits.</p>";
} ?>
<?php
$membership = "pAB7";
if (strstr($membership, "AB")) {
echo "<p>Your membership expires soon!</p>";
} else {
echo "<p>Thank you!</p>";
}
?>
<?php
$membership = "mz00xyz";
if (strpos($membership, "mz") === 0) {
echo "Hello mz!";
} ?>
<?php
$test = "pierre@wanadoo.fr";
if ($test = substr($test, -3) == ".fr") {
echo "<p>Bonjour! Nous avons des prix spéciaux de
vous.</p>";
} else {
echo "<p>Welcome to our store.</p>";
}
?>
The end.
<?php
$membership = "mz05xyz";
$membership = substr_replace($membership,
"06", 2, 2);
echo "New membership number: $membership";
// prints "New membership number:
mz06xyz"
?>
<?php
$string = "<h1>The 2005 Guide to All
Things Good in the World</h1>";
$string .= "<p>Site contents copyright
2005.</p>";
echo str_replace("2005","2006",$string);
?>
m Month of year 2
(numberleading zeroes)
M Month of year (three letters) Feb
n Month of year (numberno 2
leading zeroes)