Basic

Overview

This example will run a basic horizontal progress bar with absolute position.

Screenshot

sample screenshot

Demonstration

Give it a try

Dependencies

This example requires mandatory resources :

Explains step by step

HTML page has #E0E0E0 background color (line 17), while progress bar is absolute positionned (line 39, options top and left) on top of the blank 400x200 pixels area (line 18, see css declarations).

The progress bar size are: 300 pixels width (default) and 30 pixels height (see line 39).

The simple static text label (line 42) is default left aligned on top of the progress bar.

Source Code

  1. <!--
  2.   Demonstration of the basic features of Progress2_Lite
  3.   version of Progress2 without any dependencies
  4.  
  5.   @version    $Id: litebasic.php,v 1.1 2005/06/12 21:05:18 farell Exp $
  6.   @author     Laurent Laville <pear@laurent-laville.org>
  7.   @package    HTML_Progress2
  8.   @subpackage Examples
  9.   @access     public
  10. // -->
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  12.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  13. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  14. <head>
  15. <title>Progress2 Lite - Simple Example</title>
  16. </head>
  17. <body bgcolor="#E0E0E0">
  18. <p style="background-color:white;width:400px;height:200px;">&nbsp;</p>
  19. <h1>Positionning sheme</h1>
  20. <p>Default behaviour.</p>
  21.  
  22. <?php
  23. require_once 'HTML/Progress2_Lite.php';
  24.  
  25. /**
  26. * NOTE: The function {@link http://www.php.net/manual/en/function.usleep.php}
  27. *       did not work on Windows systems until PHP 5.0.0
  28. */
  29. function _sleep($usecs)
  30. {
  31.     if ((substr(PHP_OS, 0, 3) == 'WIN') && (substr(PHP_VERSION,0,1) < '5') ){
  32.         for ($i=0; $i<$usecs; $i++) { }
  33.     } else {
  34.         usleep($usecs);
  35.     }
  36. }
  37.  
  38. // Creates a new progress bar 300 pixels width and 30 pixels height
  39. $pbl = new HTML_Progress2_Lite(array('top' => 80, 'left' => 50, 'height' => 30));
  40.  
  41. // Adds additional text label
  42. $pbl->addLabel('text','txt1','Progress2 Lite - Simple Example');
  43.  
  44. // Show the progress bar
  45. $pbl->display();
  46.  
  47. // Processes
  48. for($i=1; $i<=100; $i++) {
  49.     $pbl->moveStep($i);
  50.     _sleep(100000);
  51. }
  52. ?>
  53. </body>
  54. </html>