1--TEST--
2Test chr() function : usage variations - test values for $ascii argument
3--FILE--
4<?php
5
6echo "*** Testing chr() function: with unexpected inputs for 'ascii' argument ***\n";
7
8//get an unset variable
9$unset_var = 'string_val';
10unset($unset_var);
11
12//defining a class
13class sample  {
14  public function __toString() {
15    return "sample object";
16  }
17}
18
19//getting the resource
20$file_handle = fopen(__FILE__, "r");
21
22// array with different values for $input
23$inputs =  array (
24
25          // integer values
26/*1*/	  0,
27          1,
28          255,
29          256,
30
31          // float values
32/*5*/	  10.5,
33          -20.5,
34          1.1234e6,
35
36          // boolean values
37/*11*/	  true,
38          false,
39          TRUE,
40          FALSE,
41
42          // null values
43/*15*/	  NULL,
44          null,
45
46          // undefined variable
47/*19*/	  @$undefined_var,
48
49          // unset variable
50/*20*/	  @$unset_var
51);
52
53// loop through with each element of the $inputs array to test chr() function
54$count = 1;
55foreach($inputs as $input) {
56  echo "-- Iteration $count --\n";
57  var_dump( bin2hex(chr($input)) );
58  $count ++;
59}
60
61fclose($file_handle);  //closing the file handle
62
63?>
64--EXPECT--
65*** Testing chr() function: with unexpected inputs for 'ascii' argument ***
66-- Iteration 1 --
67string(2) "00"
68-- Iteration 2 --
69string(2) "01"
70-- Iteration 3 --
71string(2) "ff"
72-- Iteration 4 --
73string(2) "00"
74-- Iteration 5 --
75string(2) "0a"
76-- Iteration 6 --
77string(2) "ec"
78-- Iteration 7 --
79string(2) "48"
80-- Iteration 8 --
81string(2) "01"
82-- Iteration 9 --
83string(2) "00"
84-- Iteration 10 --
85string(2) "01"
86-- Iteration 11 --
87string(2) "00"
88-- Iteration 12 --
89string(2) "00"
90-- Iteration 13 --
91string(2) "00"
92-- Iteration 14 --
93string(2) "00"
94-- Iteration 15 --
95string(2) "00"
96