This concluding article in the series illustrates PHP's filefunctions, with examples of how to read and write files on the system. Italso includes an explanation of user-defined functions, return values andfunction arguments, together with some not-so-real-life examples.
<html>
<head>
<basefont face=Arial>
</head>
<body>
<?php
function answer_yes()
{
echo "Yes!";
}
function answer_no()
{
echo "No!";
}
?>
Would you watch an Al Pacino movie without thinking twice?
<br>
<? answer_yes(); ?>
<p>
Does 2 + 2 equal 6?
<br>
<? answer_no(); ?>
<p>
Is this the coolest PHP tutorial on the planet?
<br>
<? answer_yes(); ?>
</body>
</html>
And here's the output:
Would you watch an Al Pacino movie without thinking twice?
Yes!
Does 2 + 2 equal 6?
No!
Is this the coolest PHP tutorial on the planet?
Yes!
You can also invoke a function before it's been defined.
<html>
<head>
<basefont face=Arial>
</head>
<body>
Would you watch an Al Pacino movie without thinking twice?
<br>
<? answer_yes(); ?>
<p>
Does 2 + 2 equal 6?
<br>
<? answer_no(); ?>
<p>
Is this the coolest PHP tutorial on the planet?
<br>
<? answer_yes(); ?>
<?php
function answer_yes()
{
echo "Yes!";
}
function answer_no()
{
echo "No!";
}
?>
</body>
</html>