Var_Dump
[ class tree: Var_Dump ] [ index: Var_Dump ] [ all elements ]

Source for file example-1.php

Documentation is available at example-1.php

  1. <?php
  2. header('Content-Type: application/xhtml+xml; charset=utf-8');
  3. header('Vary: Accept')
  4. ?>
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  7.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  9. <head>
  10.     <title>An XHTML 1.0 Strict standard template</title>
  11.     <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  12.     <meta http-equiv="Content-Style-Type" content="text/css" />
  13. </head>
  14. <body>
  15.  
  16. <?php
  17.  
  18. include_once 'Var_Dump.php';
  19.  
  20. echo '<h1>example1.php : displaying a variable</h1>';
  21.  
  22. /*
  23.  * example1.php : displaying a variable
  24.  *
  25.  * To display a variable :
  26.  *
  27.  *   Var_Dump::display($variable);
  28.  *
  29.  * To return a variable :
  30.  *
  31.  *   $str = Var_Dump::display($variable, TRUE);
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Initialise the HTML4 Table rendering
  37.  */
  38.  
  39. Var_Dump::displayInit(array('display_mode' => 'HTML4_Table'));
  40.  
  41. /*
  42.  * Displays an array
  43.  */
  44.  
  45. echo '<h2>Array</h2>';
  46.  
  47. $fileHandler tmpfile();
  48. $linkedArray = array('John''Jack''Bill');
  49. $array = array(
  50.     'key-1' => 'The quick brown fox jumped over the lazy dog',
  51.     'key-2' => 234,
  52.     'key-3' => array(
  53.         'key-3-1' => 31.789,
  54.         'key-3-2' => $linkedArray,
  55.         'file'    => $fileHandler
  56.     ),
  57.     'key-4' => NULL
  58. );
  59. Var_Dump::display($array);
  60.  
  61. /*
  62.  * Displays an object (with recursion)
  63.  */
  64.  
  65. echo '<h2>Object (Recursive)</h2>';
  66.  
  67. class c_parent {
  68.     function c_parent({
  69.         $this->myChild = new child($this);
  70.         $this->myName 'c_parent';
  71.     }
  72. }
  73. class child {
  74.     function child($c_parent{
  75.         $this->myParent $c_parent;
  76.     }
  77. }
  78. $recursiveObject = new c_parent();
  79. Var_Dump::display($recursiveObject);
  80.  
  81. /*
  82.  * Displays a classic object
  83.  */
  84.  
  85. echo '<h2>Object (Classic)</h2>';
  86.  
  87. class test {
  88.     var $foo = 0;
  89.     var $bar '';
  90.     function get_foo({
  91.         return $this->foo;
  92.     }
  93.     function get_bar({
  94.         return $this->bar;
  95.     }
  96. }
  97. $object = new test();
  98. $object->foo = 753;
  99. $object->bar = '357';
  100. Var_Dump::display($object);
  101.  
  102. fclose($fileHandler);
  103.  
  104. ?>
  105.  
  106. </body>
  107. </html>

Documentation generated on Mon, 11 Mar 2019 15:38:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.