Fill out power.php bellow:

  1. <!DOCTYPE {3:SAC:=}3{html:SAC:=}>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Power</title>
  6. </head>
  7. <body>
  8. <h1>Power</h1>
  9. <?php
  10. {5:SAC:=}5{function:SAC:=} show($text, $val, $unit) {
  11. echo '<p>'.$text.' = '.$val.' '.$unit.'</p>' ;
  12. }
  13. $factor = ($_POST['unit'] == 'mA') ? .001 : 1 ;
  14. $V = $_POST['voltage'] ;
  15. $I = $_POST['current'] * $factor ;
  16. $P = $V * $I ;
  17. show('Voltage', $V, 'V') ;
  18. show('Current', $I, 'A') ;
  19. show('Power', $P, 'W') ;
  20. ?>
  21. <p><a href="power.html">Do it again</a></p>
  22. </body>
  23. </html>