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.     array(
  34.         'display_mode' => 'HTML4_Table'
  35.     ),
  36.     array(
  37.         'show_caption'   => FALSE,
  38.         'bordercolor'    => '#DDDDDD',
  39.         'bordersize'     => '2',
  40.         'captioncolor'   => 'white',
  41.         'cellpadding'    => '4',
  42.         'cellspacing'    => '0',
  43.         'color1'         => '#FFFFFF',
  44.         'color2'         => '#F4F4F4',
  45.         'before_num_key' => '<font color="#CC5450"><b>',
  46.         'after_num_key'  => '</b></font>',
  47.         'before_str_key' => '<font color="#5450CC">',
  48.         'after_str_key'  => '</font>',
  49.         'before_value'   => '<i>',
  50.         'after_value'    => '</i>'
  51.     )
  52. );
  53.  
  54. /*
  55.  * Displays an array
  56.  */
  57.  
  58. echo '<h2>Array</h2>';
  59.  
  60. $fileHandler tmpfile();
  61. $linkedArray = array('John''Jack''Bill');
  62. $array = array(
  63.     'key-1' => 'The quick brown fox jumped over the lazy dog',
  64.     'key-2' => 234,
  65.     'key-3' => array(
  66.         'key-3-1' => 31.789,
  67.         'key-3-2' => $linkedArray,
  68.         'file'    => $fileHandler
  69.     ),
  70.     'key-4' => NULL
  71. );
  72. Var_Dump::display($array);
  73.  
  74. /*
  75.  * Displays an object (with recursion)
  76.  */
  77.  
  78. echo '<h2>Object (Recursive)</h2>';
  79.  
  80. class c_parent {
  81.     function c_parent({
  82.         $this->myChild = new child($this);
  83.         $this->myName 'c_parent';
  84.     }
  85. }
  86. class child {
  87.     function child($c_parent{
  88.         $this->myParent $c_parent;
  89.     }
  90. }
  91. $recursiveObject = new c_parent();
  92. Var_Dump::display($recursiveObject);
  93.  
  94. /*
  95.  * Displays a classic object
  96.  */
  97.  
  98. echo '<h2>Object (Classic)</h2>';
  99.  
  100. class test {
  101.     var $foo = 0;
  102.     var $bar '';
  103.     function get_foo({
  104.         return $this->foo;
  105.     }
  106.     function get_bar({
  107.         return $this->bar;
  108.     }
  109. }
  110. $object = new test();
  111. $object->foo = 753;
  112. $object->bar = '357';
  113. Var_Dump::display($object);
  114.  
  115. fclose($fileHandler);
  116.  
  117. ?>
  118.  
  119. </body>
  120. </html>

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