Section A.11. Chapter 11


A.11. Chapter 11


Solution to Question 11-1

The printf() function prints to the output of your program, while sprintf() sends its output to a variable that you specify as one of its parameters.


Solution to Question 11-2

Check whether or not the date 1/31/2045 is valid as follows:

 if (checkdate(1,31,2045)) {     echo('Date is valid.');   }   else {     echo ('Invalid date.');   } 


Solution to Question 11-3

To display the day of the week for 1/31/2045, you must first create a timestamp for that date. The l in the format string for date() indicates that the full day of the week displays.

 <?php $timestamp= mktime(1,31,2045); echo date("l",$timestamp); ?> 


Solution to Question 11-4

To rename the file upload.tmp to sample.jpg, specify:

 <?php $status=rename('upload.tmp','sample.jpg');   if ($status) {     echo ("Renamed file.");   } ?> 



Learning PHP and MySQL
Learning PHP and MySQL
ISBN: 0596101104
EAN: 2147483647
Year: N/A
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net