HTML and CSS Reference
In-Depth Information
<title> Current Temperature </title>
</head>
<body>
<p> Current temperature in Fahrenheit: <?= celsiusToFahrenheit(55) ?></p>
</body>
</html>
As you can see, in this case the page won't have any meaning if the function in the
library page is not available, so using require makes sense. On this page, it wouldn't
matter whether I used require or require_once because there are no other includes.
Suppose that the page included another file, one that prints the current temperatures
around the world. If that page also had a require() call for
temperature_converter.php , the same code would be included twice. An error would
cause the page to fail, because each function name can only be declared once. Using
require_once ensures that your library code is available and that it is not accidentally
included in your page multiple times.
On the other hand, if you're including content that will be displayed within your page,
then include or require make more sense. You don't have to worry about conflicts, and
if you're including something to be displayed on the page, chances are you want it to
appear, even if you've already included the same thing.
Expanding Your Knowledge of PHP
PHP is a full-featured scripting language for creating web applications and even writing
command-line scripts. What you've seen in this lesson is just a brief introduction to the
language. There are more statements, lots more built-in functions, and plenty of other
things about the application for which there isn't space to discuss in this lesson.
Fortunately, an online version of the PHP manual is available that will fill in most of the
blanks for you. You can find it at http://www.php.net/docs.php.
Also, shelves of books about PHP are available to you. Some that you might want to
look into are Sams Teach Yourself PHP, MySQL, and Apache All in One (ISBN
067232976X), and PHP and MySQL Web Development (ISBN 0672317842).
There's more to PHP than just the core language, too. Lots of libraries have been written
by users to take care of common programming tasks that you might run into. There's an
online repository for these libraries called PEAR, which stands for PHP Extension and
Application Repository. You can find it at http://pear.php.net/.
 
 
Search WWH ::




Custom Search