02.8: Printf

How do we format our output and make it look nice? PHP offers a print format (printf) function.


https://www.youtube.com/watch?v=6vicleXxZjk





<?php
# * printf()

$name = "Eric";

printf ("name: %s\n", $name);


$num1 = 10;
$num2 = 5;

printf ("num1: %d\n", $num1);
printf ("num2: %2d\n", $num2);



# * Exersize 1: Write a program to print a string $name that is enclosed in single quotes.

# * Exersize 2: Give the temperature conversion program a header line and formatted output.

/* Sample output
  0
  1
..
  9
 10
..
 99
100
..
*/

?>