Learning PHP and MySQL

A.5. Chapter 5

Solution to Question 5-1

This isn't a valid function. It's missing the parentheses and furthermore, it's bad style to mix functions with your main code.

Solution to Question 5-2

To define the toast function with a parameter:

<?php function toast( $minutes ) { //do the toasting here echo ("done."); } ?>

Solution to Question 5-3

To call toast with 5 as the minutes parameter:

<?php toast(5); ?>

Solution to Question 5-4

When you are using include() and a file can't be found, only a warning issues. However, when you are using require(), a missing file causes a fatal error that terminates the execution of the script.

Solution to Question 5-5

A method.

Категории