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

Source for file example-2.php

Documentation is available at example-2.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>example2.php : singleton approach</h1>';
  21.  
  22. /*
  23.  * example2.php : Singleton approach
  24.  *
  25.  * Var_Dump::display() uses a singleton pattern, so if you want to
  26.  * use this method, and configure the output to your needs, you will have
  27.  * to call before the displayInit method with the appropriate parameters.
  28.  * (for instance in the auto_prepend file)
  29.  *
  30.  */
  31.  
  32. // Initialise the HTML4 Table rendering (see Var_Dump/Renderer/HTML4_Table.php)
  33. Var_Dump::displayInit(
  34.     array(
  35.         'display_mode' => 'HTML4_Table'
  36.     ),
  37.     array(
  38.         'show_caption'   => FALSE,
  39.         'bordercolor'    => '#DDDDDD',
  40.         'bordersize'     => '2',
  41.         'captioncolor'   => 'white',
  42.         'cellpadding'    => '4',
  43.         'cellspacing'    => '0',
  44.         'color1'         => '#FFFFFF',
  45.         'color2'         => '#F4F4F4',
  46.         'before_num_key' => '<font color="#CC5450"><b>',
  47.         'after_num_key'  => '</b></font>',
  48.         'before_str_key' => '<font color="#5450CC">',
  49.         'after_str_key'  => '</font>',
  50.         'before_value'   => '<i>',
  51.         'after_value'    => '</i>'
  52.     )
  53. );
  54.  
  55. /*
  56.  * Displays an array
  57.  */
  58.  
  59. echo '<h2>Array</h2>';
  60.  
  61. $fileHandler tmpfile();
  62. $linkedArray = array('John''Jack''Bill');
  63. $array = array(
  64.     'key-1' => 'The quick brown fox jumped over the lazy dog',
  65.     'key-2' => 234,
  66.     'key-3' => array(
  67.         'key-3-1' => 31.789,
  68.         'key-3-2' => $linkedArray,
  69.         'file'    => $fileHandler
  70.     ),
  71.     'key-4' => NULL
  72. );
  73. Var_Dump::display($array);
  74.  
  75. /*
  76.  * Displays an object (with recursion)
  77.  */
  78.  
  79. echo '<h2>Object (Recursive)</h2>';
  80.  
  81. class c_parent {
  82.     function c_parent({
  83.         $this->myChild = new child($this);
  84.         $this->myName 'c_parent';
  85.     }
  86. }
  87. class child {
  88.     function child($c_parent{
  89.         $this->myParent $c_parent;
  90.     }
  91. }
  92. $recursiveObject = new c_parent();
  93. Var_Dump::display($recursiveObject);
  94.  
  95. /*
  96.  * Displays a classic object
  97.  */
  98.  
  99. echo '<h2>Object (Classic)</h2>';
  100.  
  101. class test {
  102.     var $foo = 0;
  103.     var $bar '';
  104.     function get_foo({
  105.         return $this->foo;
  106.     }
  107.     function get_bar({
  108.         return $this->bar;
  109.     }
  110. }
  111. $object = new test();
  112. $object->foo = 753;
  113. $object->bar = '357';
  114. Var_Dump::display($object);
  115.  
  116. fclose($fileHandler);
  117.  
  118. ?>
  119.  
  120. </body>
  121. </html>

Documentation generated on Mon, 11 Mar 2019 14:36:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.