New version of gettype_settype_variation1.phpt gettype_settype_variation6.phpt

gettype_settype_variation2.phpt  gettype_settype_variation7.phpt      gettype_settype_variation3.phpt  gettype_settype_variation8.phpt
gettype_settype_basic.phpt  gettype_settype_variation4.phpt
gettype_settype_error.phpt  gettype_settype_variation5.phpt
This commit is contained in:
Raghubansh Kumar 2007-05-22 16:01:59 +00:00
parent 9f5016ef7b
commit 17a6ac36da
10 changed files with 7705 additions and 0 deletions

View file

@ -0,0 +1,904 @@
--TEST--
Test gettype() & settype() functions : basic functionalities
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test the basic functionalities of settype() & gettype() functions.
Use the gettype() to get the type of regular data and use settype()
to change its type to other types */
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
echo "**** Testing gettype() and settype() functions ****\n";
$fp = fopen(__FILE__, "r");
$dfp = opendir( dirname(__FILE__) );
$var1 = "another string";
$var2 = array(2,3,4);
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "Object";
}
}
$unset_var = 10;
unset($unset_var);
$values = array(
array(1,2,3),
$var1,
$var2,
1,
-20,
2.54,
-2.54,
NULL,
false,
"some string",
'string',
$fp,
$dfp,
new point(10,20)
);
$types = array(
"null",
"integer",
"int",
"float",
"double",
"boolean",
"bool",
"resource",
"array",
"object",
"string"
);
echo "\n*** Testing gettype(): basic operations ***\n";
foreach ($values as $value) {
var_dump( gettype($value) );
}
echo "\n*** Testing settype(): basic operations ***\n";
foreach ($types as $type) {
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count ++;
// set to new type
var_dump( settype($var, $type) );
// dump the var
var_dump( $var );
// check the new type
var_dump( gettype($var) );
}
}
echo "Done\n";
?>
--EXPECTF--
**** Testing gettype() and settype() functions ****
*** Testing gettype(): basic operations ***
string(5) "array"
string(6) "string"
string(5) "array"
string(7) "integer"
string(7) "integer"
string(6) "double"
string(6) "double"
string(4) "NULL"
string(7) "boolean"
string(6) "string"
string(6) "string"
string(8) "resource"
string(8) "resource"
string(6) "object"
*** Testing settype(): basic operations ***
-- Setting type of data to null --
-- Iteration 1 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 2 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 3 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 4 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 5 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 6 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 7 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 8 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 9 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 10 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 11 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 12 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 13 --
bool(true)
NULL
string(4) "NULL"
-- Iteration 14 --
bool(true)
NULL
string(4) "NULL"
-- Setting type of data to integer --
-- Iteration 1 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 2 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 3 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 4 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 5 --
bool(true)
int(-20)
string(7) "integer"
-- Iteration 6 --
bool(true)
int(2)
string(7) "integer"
-- Iteration 7 --
bool(true)
int(-2)
string(7) "integer"
-- Iteration 8 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 9 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 10 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 11 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 12 --
bool(true)
int(5)
string(7) "integer"
-- Iteration 13 --
bool(true)
int(6)
string(7) "integer"
-- Iteration 14 --
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Setting type of data to int --
-- Iteration 1 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 2 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 3 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 4 --
bool(true)
int(1)
string(7) "integer"
-- Iteration 5 --
bool(true)
int(-20)
string(7) "integer"
-- Iteration 6 --
bool(true)
int(2)
string(7) "integer"
-- Iteration 7 --
bool(true)
int(-2)
string(7) "integer"
-- Iteration 8 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 9 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 10 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 11 --
bool(true)
int(0)
string(7) "integer"
-- Iteration 12 --
bool(true)
int(5)
string(7) "integer"
-- Iteration 13 --
bool(true)
int(6)
string(7) "integer"
-- Iteration 14 --
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Setting type of data to float --
-- Iteration 1 --
bool(true)
float(1)
string(6) "double"
-- Iteration 2 --
bool(true)
float(0)
string(6) "double"
-- Iteration 3 --
bool(true)
float(1)
string(6) "double"
-- Iteration 4 --
bool(true)
float(1)
string(6) "double"
-- Iteration 5 --
bool(true)
float(-20)
string(6) "double"
-- Iteration 6 --
bool(true)
float(2.54)
string(6) "double"
-- Iteration 7 --
bool(true)
float(-2.54)
string(6) "double"
-- Iteration 8 --
bool(true)
float(0)
string(6) "double"
-- Iteration 9 --
bool(true)
float(0)
string(6) "double"
-- Iteration 10 --
bool(true)
float(0)
string(6) "double"
-- Iteration 11 --
bool(true)
float(0)
string(6) "double"
-- Iteration 12 --
bool(true)
float(5)
string(6) "double"
-- Iteration 13 --
bool(true)
float(6)
string(6) "double"
-- Iteration 14 --
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Setting type of data to double --
-- Iteration 1 --
bool(true)
float(1)
string(6) "double"
-- Iteration 2 --
bool(true)
float(0)
string(6) "double"
-- Iteration 3 --
bool(true)
float(1)
string(6) "double"
-- Iteration 4 --
bool(true)
float(1)
string(6) "double"
-- Iteration 5 --
bool(true)
float(-20)
string(6) "double"
-- Iteration 6 --
bool(true)
float(2.54)
string(6) "double"
-- Iteration 7 --
bool(true)
float(-2.54)
string(6) "double"
-- Iteration 8 --
bool(true)
float(0)
string(6) "double"
-- Iteration 9 --
bool(true)
float(0)
string(6) "double"
-- Iteration 10 --
bool(true)
float(0)
string(6) "double"
-- Iteration 11 --
bool(true)
float(0)
string(6) "double"
-- Iteration 12 --
bool(true)
float(5)
string(6) "double"
-- Iteration 13 --
bool(true)
float(6)
string(6) "double"
-- Iteration 14 --
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Setting type of data to boolean --
-- Iteration 1 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 2 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 3 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 4 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 5 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 6 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 7 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 8 --
bool(true)
bool(false)
string(7) "boolean"
-- Iteration 9 --
bool(true)
bool(false)
string(7) "boolean"
-- Iteration 10 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 11 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 12 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 13 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 14 --
bool(true)
bool(true)
string(7) "boolean"
-- Setting type of data to bool --
-- Iteration 1 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 2 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 3 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 4 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 5 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 6 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 7 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 8 --
bool(true)
bool(false)
string(7) "boolean"
-- Iteration 9 --
bool(true)
bool(false)
string(7) "boolean"
-- Iteration 10 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 11 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 12 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 13 --
bool(true)
bool(true)
string(7) "boolean"
-- Iteration 14 --
bool(true)
bool(true)
string(7) "boolean"
-- Setting type of data to resource --
-- Iteration 1 --
2: settype(): Cannot convert to resource type
bool(false)
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
string(5) "array"
-- Iteration 2 --
2: settype(): Cannot convert to resource type
bool(false)
string(14) "another string"
string(6) "string"
-- Iteration 3 --
2: settype(): Cannot convert to resource type
bool(false)
array(3) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(4)
}
string(5) "array"
-- Iteration 4 --
2: settype(): Cannot convert to resource type
bool(false)
int(1)
string(7) "integer"
-- Iteration 5 --
2: settype(): Cannot convert to resource type
bool(false)
int(-20)
string(7) "integer"
-- Iteration 6 --
2: settype(): Cannot convert to resource type
bool(false)
float(2.54)
string(6) "double"
-- Iteration 7 --
2: settype(): Cannot convert to resource type
bool(false)
float(-2.54)
string(6) "double"
-- Iteration 8 --
2: settype(): Cannot convert to resource type
bool(false)
NULL
string(4) "NULL"
-- Iteration 9 --
2: settype(): Cannot convert to resource type
bool(false)
bool(false)
string(7) "boolean"
-- Iteration 10 --
2: settype(): Cannot convert to resource type
bool(false)
string(11) "some string"
string(6) "string"
-- Iteration 11 --
2: settype(): Cannot convert to resource type
bool(false)
string(6) "string"
string(6) "string"
-- Iteration 12 --
2: settype(): Cannot convert to resource type
bool(false)
resource(5) of type (stream)
string(8) "resource"
-- Iteration 13 --
2: settype(): Cannot convert to resource type
bool(false)
resource(6) of type (stream)
string(8) "resource"
-- Iteration 14 --
2: settype(): Cannot convert to resource type
bool(false)
object(point)#1 (2) {
["x"]=>
int(10)
["y"]=>
int(20)
}
string(6) "object"
-- Setting type of data to array --
-- Iteration 1 --
bool(true)
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
string(5) "array"
-- Iteration 2 --
bool(true)
array(1) {
[0]=>
string(14) "another string"
}
string(5) "array"
-- Iteration 3 --
bool(true)
array(3) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(4)
}
string(5) "array"
-- Iteration 4 --
bool(true)
array(1) {
[0]=>
int(1)
}
string(5) "array"
-- Iteration 5 --
bool(true)
array(1) {
[0]=>
int(-20)
}
string(5) "array"
-- Iteration 6 --
bool(true)
array(1) {
[0]=>
float(2.54)
}
string(5) "array"
-- Iteration 7 --
bool(true)
array(1) {
[0]=>
float(-2.54)
}
string(5) "array"
-- Iteration 8 --
bool(true)
array(0) {
}
string(5) "array"
-- Iteration 9 --
bool(true)
array(1) {
[0]=>
bool(false)
}
string(5) "array"
-- Iteration 10 --
bool(true)
array(1) {
[0]=>
string(11) "some string"
}
string(5) "array"
-- Iteration 11 --
bool(true)
array(1) {
[0]=>
string(6) "string"
}
string(5) "array"
-- Iteration 12 --
bool(true)
array(1) {
[0]=>
resource(5) of type (stream)
}
string(5) "array"
-- Iteration 13 --
bool(true)
array(1) {
[0]=>
resource(6) of type (stream)
}
string(5) "array"
-- Iteration 14 --
bool(true)
array(2) {
["x"]=>
int(10)
["y"]=>
int(20)
}
string(5) "array"
-- Setting type of data to object --
-- Iteration 1 --
bool(true)
object(stdClass)#2 (3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
string(6) "object"
-- Iteration 2 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
string(14) "another string"
}
string(6) "object"
-- Iteration 3 --
bool(true)
object(stdClass)#2 (3) {
[0]=>
int(2)
[1]=>
int(3)
[2]=>
int(4)
}
string(6) "object"
-- Iteration 4 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
int(1)
}
string(6) "object"
-- Iteration 5 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
int(-20)
}
string(6) "object"
-- Iteration 6 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
float(2.54)
}
string(6) "object"
-- Iteration 7 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
float(-2.54)
}
string(6) "object"
-- Iteration 8 --
bool(true)
object(stdClass)#2 (0) {
}
string(6) "object"
-- Iteration 9 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
bool(false)
}
string(6) "object"
-- Iteration 10 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
string(11) "some string"
}
string(6) "object"
-- Iteration 11 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
string(6) "string"
}
string(6) "object"
-- Iteration 12 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
resource(5) of type (stream)
}
string(6) "object"
-- Iteration 13 --
bool(true)
object(stdClass)#2 (1) {
["scalar"]=>
resource(6) of type (stream)
}
string(6) "object"
-- Iteration 14 --
bool(true)
object(point)#1 (2) {
["x"]=>
int(10)
["y"]=>
int(20)
}
string(6) "object"
-- Setting type of data to string --
-- Iteration 1 --
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 2 --
bool(true)
string(14) "another string"
string(6) "string"
-- Iteration 3 --
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 4 --
bool(true)
string(1) "1"
string(6) "string"
-- Iteration 5 --
bool(true)
string(3) "-20"
string(6) "string"
-- Iteration 6 --
bool(true)
string(4) "2.54"
string(6) "string"
-- Iteration 7 --
bool(true)
string(5) "-2.54"
string(6) "string"
-- Iteration 8 --
bool(true)
string(0) ""
string(6) "string"
-- Iteration 9 --
bool(true)
string(0) ""
string(6) "string"
-- Iteration 10 --
bool(true)
string(11) "some string"
string(6) "string"
-- Iteration 11 --
bool(true)
string(6) "string"
string(6) "string"
-- Iteration 12 --
bool(true)
string(14) "Resource id #5"
string(6) "string"
-- Iteration 13 --
bool(true)
string(14) "Resource id #6"
string(6) "string"
-- Iteration 14 --
bool(true)
string(6) "Object"
string(6) "string"
Done

View file

@ -0,0 +1,56 @@
--TEST--
Test gettype() & settype() functions : error conditions
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test different error conditions of settype() and gettype() functions */
echo "**** Testing gettype() and settype() functions ****\n";
echo "\n*** Testing gettype(): error conditions ***\n";
//Zero arguments
var_dump( gettype() );
// args more than expected
var_dump( gettype( "1", "2" ) );
echo "\n*** Testing settype(): error conditions ***\n";
//Zero arguments
var_dump( settype() );
// args more than expected
$var = 10.5;
var_dump( settype( $var, $var, "int" ) );
// passing an invalid type to set
var_dump( settype( $var, "unknown" ) );
echo "Done\n";
?>
--EXPECTF--
**** Testing gettype() and settype() functions ****
*** Testing gettype(): error conditions ***
Warning: Wrong parameter count for gettype() in %s on line %d
NULL
Warning: Wrong parameter count for gettype() in %s on line %d
NULL
*** Testing settype(): error conditions ***
Warning: Wrong parameter count for settype() in %s on line %d
NULL
Warning: Wrong parameter count for settype() in %s on line %d
NULL
Warning: settype(): Invalid type in %s on line %d
bool(false)
Done

View file

@ -0,0 +1,583 @@
--TEST--
Test gettype() & settype() functions : usage variatoins
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to null type.
Set type of the data to "null" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to "null type"
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
/* test conversion to null type */
$type = "null";
echo "\n*** Testing gettype() & settype() functions : usage variations ***\n";
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to null
var_dump( settype($var, $type) );
// dump the converted data
var_dump( $var );
// check the new type after conversion
var_dump( gettype($var) );
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing gettype() & settype() functions : usage variations ***
-- Setting type of data to null --
-- Iteration 1 --
string(4) "NULL"
bool(true)
NULL
string(4) "NULL"
-- Iteration 2 --
string(7) "boolean"
bool(true)
NULL
string(4) "NULL"
-- Iteration 3 --
string(7) "boolean"
bool(true)
NULL
string(4) "NULL"
-- Iteration 4 --
string(7) "boolean"
bool(true)
NULL
string(4) "NULL"
-- Iteration 5 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 6 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 7 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 8 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 9 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 10 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 11 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 12 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 13 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 14 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 15 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 16 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 17 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 18 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 19 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 20 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 21 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 22 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 23 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 24 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 25 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 26 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 27 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 28 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 29 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 30 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 31 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 32 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 33 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 34 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 35 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 36 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 37 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 38 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 39 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 40 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 41 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 42 --
string(6) "string"
bool(true)
NULL
string(4) "NULL"
-- Iteration 43 --
string(5) "array"
bool(true)
NULL
string(4) "NULL"
-- Iteration 44 --
string(5) "array"
bool(true)
NULL
string(4) "NULL"
-- Iteration 45 --
string(5) "array"
bool(true)
NULL
string(4) "NULL"
-- Iteration 46 --
string(5) "array"
bool(true)
NULL
string(4) "NULL"
-- Iteration 47 --
string(5) "array"
bool(true)
NULL
string(4) "NULL"
-- Iteration 48 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 49 --
string(7) "integer"
bool(true)
NULL
string(4) "NULL"
-- Iteration 50 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 51 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 52 --
string(7) "integer"
bool(true)
NULL
string(4) "NULL"
-- Iteration 53 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 54 --
string(7) "integer"
bool(true)
NULL
string(4) "NULL"
-- Iteration 55 --
string(7) "integer"
bool(true)
NULL
string(4) "NULL"
-- Iteration 56 --
string(7) "integer"
bool(true)
NULL
string(4) "NULL"
-- Iteration 57 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 58 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 59 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 60 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 61 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 62 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 63 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 64 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 65 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 66 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 67 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 68 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 69 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 70 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 71 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 72 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 73 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 74 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 75 --
string(6) "double"
bool(true)
NULL
string(4) "NULL"
-- Iteration 76 --
string(6) "object"
bool(true)
NULL
string(4) "NULL"
-- Iteration 77 --
string(6) "object"
bool(true)
NULL
string(4) "NULL"
-- Iteration 78 --
string(6) "object"
bool(true)
NULL
string(4) "NULL"
-- Iteration 79 --
string(4) "NULL"
bool(true)
NULL
string(4) "NULL"
-- Iteration 80 --
string(4) "NULL"
bool(true)
NULL
string(4) "NULL"
Done

View file

@ -0,0 +1,996 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to int/integer type.
Set type of the data to "int"/"integer" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to interger/int type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
// test conversion to these types
$types = array(
"integer",
"int"
);
echo "\n*** Testing settype() & gettype() : usage variations ***\n";
foreach ($types as $type) {
echo "\n-- Setting type of data to $type --\n";
$inner_loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $inner_loop_count --\n"; $inner_loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to new type
var_dump( settype($var, $type) );
// dump the converted $var
var_dump( $var );
// get the new type of the $var
var_dump( gettype($var) );
}
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing settype() & gettype() : usage variations ***
-- Setting type of data to integer --
-- Iteration 1 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
-- Iteration 2 --
string(7) "boolean"
bool(true)
int(0)
string(7) "integer"
-- Iteration 3 --
string(7) "boolean"
bool(true)
int(1)
string(7) "integer"
-- Iteration 4 --
string(7) "boolean"
bool(true)
int(1)
string(7) "integer"
-- Iteration 5 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 6 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 7 --
string(6) "string"
bool(true)
int(3)
string(7) "integer"
-- Iteration 8 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 9 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 10 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 11 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 12 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 13 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 14 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 15 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 16 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 17 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 18 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 19 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 20 --
string(6) "string"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 21 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 22 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 23 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 24 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 25 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 26 --
string(6) "string"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 27 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 28 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 29 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 30 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 31 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 32 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 33 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 34 --
string(6) "string"
bool(true)
int(-123)
string(7) "integer"
-- Iteration 35 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 36 --
string(6) "string"
bool(true)
int(-123)
string(7) "integer"
-- Iteration 37 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 38 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 39 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 40 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 41 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 42 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 43 --
string(5) "array"
bool(true)
int(0)
string(7) "integer"
-- Iteration 44 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 45 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 46 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 47 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 48 --
string(6) "double"
bool(true)
int(-2147483648)
string(7) "integer"
-- Iteration 49 --
string(7) "integer"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 50 --
string(6) "double"
bool(true)
int(-2147483647)
string(7) "integer"
-- Iteration 51 --
string(6) "double"
bool(true)
int(-508130303)
string(7) "integer"
-- Iteration 52 --
string(7) "integer"
bool(true)
int(85)
string(7) "integer"
-- Iteration 53 --
string(6) "double"
bool(true)
int(1952002105)
string(7) "integer"
-- Iteration 54 --
string(7) "integer"
bool(true)
int(-21903)
string(7) "integer"
-- Iteration 55 --
string(7) "integer"
bool(true)
int(365)
string(7) "integer"
-- Iteration 56 --
string(7) "integer"
bool(true)
int(-365)
string(7) "integer"
-- Iteration 57 --
string(6) "double"
bool(true)
int(343000682)
string(7) "integer"
-- Iteration 58 --
string(6) "double"
bool(true)
int(100000)
string(7) "integer"
-- Iteration 59 --
string(6) "double"
bool(true)
int(-100000)
string(7) "integer"
-- Iteration 60 --
string(6) "double"
bool(true)
int(100000)
string(7) "integer"
-- Iteration 61 --
string(6) "double"
bool(true)
int(-100000)
string(7) "integer"
-- Iteration 62 --
string(6) "double"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 63 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 64 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 65 --
string(6) "double"
bool(true)
int(500000)
string(7) "integer"
-- Iteration 66 --
string(6) "double"
bool(true)
int(-500000)
string(7) "integer"
-- Iteration 67 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 68 --
string(6) "double"
bool(true)
int(500000)
string(7) "integer"
-- Iteration 69 --
string(6) "double"
bool(true)
int(-500000)
string(7) "integer"
-- Iteration 70 --
string(6) "double"
bool(true)
int(512000)
string(7) "integer"
-- Iteration 71 --
string(6) "double"
bool(true)
int(-512000)
string(7) "integer"
-- Iteration 72 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 73 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 74 --
string(6) "double"
bool(true)
int(512000)
string(7) "integer"
-- Iteration 75 --
string(6) "double"
bool(true)
int(-512000)
string(7) "integer"
-- Iteration 76 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 77 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 78 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 79 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
-- Iteration 80 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
-- Setting type of data to int --
-- Iteration 1 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
-- Iteration 2 --
string(7) "boolean"
bool(true)
int(0)
string(7) "integer"
-- Iteration 3 --
string(7) "boolean"
bool(true)
int(1)
string(7) "integer"
-- Iteration 4 --
string(7) "boolean"
bool(true)
int(1)
string(7) "integer"
-- Iteration 5 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 6 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 7 --
string(6) "string"
bool(true)
int(3)
string(7) "integer"
-- Iteration 8 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 9 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 10 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 11 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 12 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 13 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 14 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 15 --
string(6) "string"
bool(true)
int(10)
string(7) "integer"
-- Iteration 16 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 17 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 18 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 19 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 20 --
string(6) "string"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 21 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 22 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 23 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 24 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 25 --
string(6) "string"
bool(true)
int(1)
string(7) "integer"
-- Iteration 26 --
string(6) "string"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 27 --
string(6) "string"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 28 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 29 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 30 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 31 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 32 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 33 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 34 --
string(6) "string"
bool(true)
int(-123)
string(7) "integer"
-- Iteration 35 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 36 --
string(6) "string"
bool(true)
int(-123)
string(7) "integer"
-- Iteration 37 --
string(6) "string"
bool(true)
int(123)
string(7) "integer"
-- Iteration 38 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 39 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 40 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 41 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 42 --
string(6) "string"
bool(true)
int(0)
string(7) "integer"
-- Iteration 43 --
string(5) "array"
bool(true)
int(0)
string(7) "integer"
-- Iteration 44 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 45 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 46 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 47 --
string(5) "array"
bool(true)
int(1)
string(7) "integer"
-- Iteration 48 --
string(6) "double"
bool(true)
int(-2147483648)
string(7) "integer"
-- Iteration 49 --
string(7) "integer"
bool(true)
int(2147483647)
string(7) "integer"
-- Iteration 50 --
string(6) "double"
bool(true)
int(-2147483647)
string(7) "integer"
-- Iteration 51 --
string(6) "double"
bool(true)
int(-508130303)
string(7) "integer"
-- Iteration 52 --
string(7) "integer"
bool(true)
int(85)
string(7) "integer"
-- Iteration 53 --
string(6) "double"
bool(true)
int(1952002105)
string(7) "integer"
-- Iteration 54 --
string(7) "integer"
bool(true)
int(-21903)
string(7) "integer"
-- Iteration 55 --
string(7) "integer"
bool(true)
int(365)
string(7) "integer"
-- Iteration 56 --
string(7) "integer"
bool(true)
int(-365)
string(7) "integer"
-- Iteration 57 --
string(6) "double"
bool(true)
int(343000682)
string(7) "integer"
-- Iteration 58 --
string(6) "double"
bool(true)
int(100000)
string(7) "integer"
-- Iteration 59 --
string(6) "double"
bool(true)
int(-100000)
string(7) "integer"
-- Iteration 60 --
string(6) "double"
bool(true)
int(100000)
string(7) "integer"
-- Iteration 61 --
string(6) "double"
bool(true)
int(-100000)
string(7) "integer"
-- Iteration 62 --
string(6) "double"
bool(true)
int(-1)
string(7) "integer"
-- Iteration 63 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 64 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 65 --
string(6) "double"
bool(true)
int(500000)
string(7) "integer"
-- Iteration 66 --
string(6) "double"
bool(true)
int(-500000)
string(7) "integer"
-- Iteration 67 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 68 --
string(6) "double"
bool(true)
int(500000)
string(7) "integer"
-- Iteration 69 --
string(6) "double"
bool(true)
int(-500000)
string(7) "integer"
-- Iteration 70 --
string(6) "double"
bool(true)
int(512000)
string(7) "integer"
-- Iteration 71 --
string(6) "double"
bool(true)
int(-512000)
string(7) "integer"
-- Iteration 72 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 73 --
string(6) "double"
bool(true)
int(0)
string(7) "integer"
-- Iteration 74 --
string(6) "double"
bool(true)
int(512000)
string(7) "integer"
-- Iteration 75 --
string(6) "double"
bool(true)
int(-512000)
string(7) "integer"
-- Iteration 76 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 77 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 78 --
string(6) "object"
8: Object of class point could not be converted to int
bool(true)
int(1)
string(7) "integer"
-- Iteration 79 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
-- Iteration 80 --
string(4) "NULL"
bool(true)
int(0)
string(7) "integer"
Done

View file

@ -0,0 +1,996 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to float/double type.
Set type of the data to "float"/"double" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to float/double type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
// test conversion to these types
$types = array(
"float",
"double"
);
echo "\n*** Testing settype() & gettype() : usage variations ***\n";
foreach ($types as $type) {
echo "\n-- Setting type of data to $type --\n";
$inner_loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $inner_loop_count --\n"; $inner_loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to new type
var_dump( settype($var, $type) );
// dump the converted $var
var_dump( $var );
// get the new type of the $var
var_dump( gettype($var) );
}
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing settype() & gettype() : usage variations ***
-- Setting type of data to float --
-- Iteration 1 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
-- Iteration 2 --
string(7) "boolean"
bool(true)
float(0)
string(6) "double"
-- Iteration 3 --
string(7) "boolean"
bool(true)
float(1)
string(6) "double"
-- Iteration 4 --
string(7) "boolean"
bool(true)
float(1)
string(6) "double"
-- Iteration 5 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 6 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 7 --
string(6) "string"
bool(true)
float(3)
string(6) "double"
-- Iteration 8 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 9 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 10 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 11 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 12 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 13 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 14 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 15 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 16 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 17 --
string(6) "string"
bool(true)
float(-1)
string(6) "double"
-- Iteration 18 --
string(6) "string"
bool(true)
float(100)
string(6) "double"
-- Iteration 19 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 20 --
string(6) "string"
bool(true)
float(2.9743947493287E+21)
string(6) "double"
-- Iteration 21 --
string(6) "string"
bool(true)
float(-0.01)
string(6) "double"
-- Iteration 22 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 23 --
string(6) "string"
bool(true)
float(-1)
string(6) "double"
-- Iteration 24 --
string(6) "string"
bool(true)
float(100)
string(6) "double"
-- Iteration 25 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 26 --
string(6) "string"
bool(true)
float(2.9743947493287E+21)
string(6) "double"
-- Iteration 27 --
string(6) "string"
bool(true)
float(-0.01)
string(6) "double"
-- Iteration 28 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 29 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 30 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 31 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 32 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 33 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 34 --
string(6) "string"
bool(true)
float(-123)
string(6) "double"
-- Iteration 35 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 36 --
string(6) "string"
bool(true)
float(-123)
string(6) "double"
-- Iteration 37 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 38 --
string(6) "string"
bool(true)
float(-0)
string(6) "double"
-- Iteration 39 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 40 --
string(6) "string"
bool(true)
float(-0)
string(6) "double"
-- Iteration 41 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 42 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 43 --
string(5) "array"
bool(true)
float(0)
string(6) "double"
-- Iteration 44 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 45 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 46 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 47 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 48 --
string(6) "double"
bool(true)
float(-2147483648)
string(6) "double"
-- Iteration 49 --
string(7) "integer"
bool(true)
float(2147483647)
string(6) "double"
-- Iteration 50 --
string(6) "double"
bool(true)
float(2147483649)
string(6) "double"
-- Iteration 51 --
string(6) "double"
bool(true)
float(1232147483649)
string(6) "double"
-- Iteration 52 --
string(7) "integer"
bool(true)
float(85)
string(6) "double"
-- Iteration 53 --
string(6) "double"
bool(true)
float(1058513956921)
string(6) "double"
-- Iteration 54 --
string(7) "integer"
bool(true)
float(-21903)
string(6) "double"
-- Iteration 55 --
string(7) "integer"
bool(true)
float(365)
string(6) "double"
-- Iteration 56 --
string(7) "integer"
bool(true)
float(-365)
string(6) "double"
-- Iteration 57 --
string(6) "double"
bool(true)
float(80561044571754)
string(6) "double"
-- Iteration 58 --
string(6) "double"
bool(true)
float(100000)
string(6) "double"
-- Iteration 59 --
string(6) "double"
bool(true)
float(-100000)
string(6) "double"
-- Iteration 60 --
string(6) "double"
bool(true)
float(100000)
string(6) "double"
-- Iteration 61 --
string(6) "double"
bool(true)
float(-100000)
string(6) "double"
-- Iteration 62 --
string(6) "double"
bool(true)
float(-1.5)
string(6) "double"
-- Iteration 63 --
string(6) "double"
bool(true)
float(0.5)
string(6) "double"
-- Iteration 64 --
string(6) "double"
bool(true)
float(-0.5)
string(6) "double"
-- Iteration 65 --
string(6) "double"
bool(true)
float(500000)
string(6) "double"
-- Iteration 66 --
string(6) "double"
bool(true)
float(-500000)
string(6) "double"
-- Iteration 67 --
string(6) "double"
bool(true)
float(-5.0E-7)
string(6) "double"
-- Iteration 68 --
string(6) "double"
bool(true)
float(500000)
string(6) "double"
-- Iteration 69 --
string(6) "double"
bool(true)
float(-500000)
string(6) "double"
-- Iteration 70 --
string(6) "double"
bool(true)
float(512000)
string(6) "double"
-- Iteration 71 --
string(6) "double"
bool(true)
float(-512000)
string(6) "double"
-- Iteration 72 --
string(6) "double"
bool(true)
float(5.12E-7)
string(6) "double"
-- Iteration 73 --
string(6) "double"
bool(true)
float(5.12E-7)
string(6) "double"
-- Iteration 74 --
string(6) "double"
bool(true)
float(512000)
string(6) "double"
-- Iteration 75 --
string(6) "double"
bool(true)
float(-512000)
string(6) "double"
-- Iteration 76 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 77 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 78 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 79 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
-- Iteration 80 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
-- Setting type of data to double --
-- Iteration 1 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
-- Iteration 2 --
string(7) "boolean"
bool(true)
float(0)
string(6) "double"
-- Iteration 3 --
string(7) "boolean"
bool(true)
float(1)
string(6) "double"
-- Iteration 4 --
string(7) "boolean"
bool(true)
float(1)
string(6) "double"
-- Iteration 5 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 6 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 7 --
string(6) "string"
bool(true)
float(3)
string(6) "double"
-- Iteration 8 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 9 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 10 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 11 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 12 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 13 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 14 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 15 --
string(6) "string"
bool(true)
float(10)
string(6) "double"
-- Iteration 16 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 17 --
string(6) "string"
bool(true)
float(-1)
string(6) "double"
-- Iteration 18 --
string(6) "string"
bool(true)
float(100)
string(6) "double"
-- Iteration 19 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 20 --
string(6) "string"
bool(true)
float(2.9743947493287E+21)
string(6) "double"
-- Iteration 21 --
string(6) "string"
bool(true)
float(-0.01)
string(6) "double"
-- Iteration 22 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 23 --
string(6) "string"
bool(true)
float(-1)
string(6) "double"
-- Iteration 24 --
string(6) "string"
bool(true)
float(100)
string(6) "double"
-- Iteration 25 --
string(6) "string"
bool(true)
float(1)
string(6) "double"
-- Iteration 26 --
string(6) "string"
bool(true)
float(2.9743947493287E+21)
string(6) "double"
-- Iteration 27 --
string(6) "string"
bool(true)
float(-0.01)
string(6) "double"
-- Iteration 28 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 29 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 30 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 31 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 32 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 33 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 34 --
string(6) "string"
bool(true)
float(-123)
string(6) "double"
-- Iteration 35 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 36 --
string(6) "string"
bool(true)
float(-123)
string(6) "double"
-- Iteration 37 --
string(6) "string"
bool(true)
float(123)
string(6) "double"
-- Iteration 38 --
string(6) "string"
bool(true)
float(-0)
string(6) "double"
-- Iteration 39 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 40 --
string(6) "string"
bool(true)
float(-0)
string(6) "double"
-- Iteration 41 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 42 --
string(6) "string"
bool(true)
float(0)
string(6) "double"
-- Iteration 43 --
string(5) "array"
bool(true)
float(0)
string(6) "double"
-- Iteration 44 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 45 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 46 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 47 --
string(5) "array"
bool(true)
float(1)
string(6) "double"
-- Iteration 48 --
string(6) "double"
bool(true)
float(-2147483648)
string(6) "double"
-- Iteration 49 --
string(7) "integer"
bool(true)
float(2147483647)
string(6) "double"
-- Iteration 50 --
string(6) "double"
bool(true)
float(2147483649)
string(6) "double"
-- Iteration 51 --
string(6) "double"
bool(true)
float(1232147483649)
string(6) "double"
-- Iteration 52 --
string(7) "integer"
bool(true)
float(85)
string(6) "double"
-- Iteration 53 --
string(6) "double"
bool(true)
float(1058513956921)
string(6) "double"
-- Iteration 54 --
string(7) "integer"
bool(true)
float(-21903)
string(6) "double"
-- Iteration 55 --
string(7) "integer"
bool(true)
float(365)
string(6) "double"
-- Iteration 56 --
string(7) "integer"
bool(true)
float(-365)
string(6) "double"
-- Iteration 57 --
string(6) "double"
bool(true)
float(80561044571754)
string(6) "double"
-- Iteration 58 --
string(6) "double"
bool(true)
float(100000)
string(6) "double"
-- Iteration 59 --
string(6) "double"
bool(true)
float(-100000)
string(6) "double"
-- Iteration 60 --
string(6) "double"
bool(true)
float(100000)
string(6) "double"
-- Iteration 61 --
string(6) "double"
bool(true)
float(-100000)
string(6) "double"
-- Iteration 62 --
string(6) "double"
bool(true)
float(-1.5)
string(6) "double"
-- Iteration 63 --
string(6) "double"
bool(true)
float(0.5)
string(6) "double"
-- Iteration 64 --
string(6) "double"
bool(true)
float(-0.5)
string(6) "double"
-- Iteration 65 --
string(6) "double"
bool(true)
float(500000)
string(6) "double"
-- Iteration 66 --
string(6) "double"
bool(true)
float(-500000)
string(6) "double"
-- Iteration 67 --
string(6) "double"
bool(true)
float(-5.0E-7)
string(6) "double"
-- Iteration 68 --
string(6) "double"
bool(true)
float(500000)
string(6) "double"
-- Iteration 69 --
string(6) "double"
bool(true)
float(-500000)
string(6) "double"
-- Iteration 70 --
string(6) "double"
bool(true)
float(512000)
string(6) "double"
-- Iteration 71 --
string(6) "double"
bool(true)
float(-512000)
string(6) "double"
-- Iteration 72 --
string(6) "double"
bool(true)
float(5.12E-7)
string(6) "double"
-- Iteration 73 --
string(6) "double"
bool(true)
float(5.12E-7)
string(6) "double"
-- Iteration 74 --
string(6) "double"
bool(true)
float(512000)
string(6) "double"
-- Iteration 75 --
string(6) "double"
bool(true)
float(-512000)
string(6) "double"
-- Iteration 76 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 77 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 78 --
string(6) "object"
8: Object of class point could not be converted to double
bool(true)
float(1)
string(6) "double"
-- Iteration 79 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
-- Iteration 80 --
string(4) "NULL"
bool(true)
float(0)
string(6) "double"
Done

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,708 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to resource type.
Set type of the data to "resource" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to resource type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
/* test conversion to resource type */
$type = "resource";
echo "\n*** Testing gettype() & settype() functions : usage variations ***\n";
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to null
var_dump( settype($var, $type) );
// dump the converted data
var_dump( $var );
// check the new type after conversion
var_dump( gettype($var) );
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing gettype() & settype() functions : usage variations ***
-- Setting type of data to resource --
-- Iteration 1 --
string(4) "NULL"
2: settype(): Cannot convert to resource type
bool(false)
NULL
string(4) "NULL"
-- Iteration 2 --
string(7) "boolean"
2: settype(): Cannot convert to resource type
bool(false)
bool(false)
string(7) "boolean"
-- Iteration 3 --
string(7) "boolean"
2: settype(): Cannot convert to resource type
bool(false)
bool(true)
string(7) "boolean"
-- Iteration 4 --
string(7) "boolean"
2: settype(): Cannot convert to resource type
bool(false)
bool(true)
string(7) "boolean"
-- Iteration 5 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) "ÿ"
string(6) "string"
-- Iteration 6 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) "f"
string(6) "string"
-- Iteration 7 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) "
3"
string(6) "string"
-- Iteration 8 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(0) ""
string(6) "string"
-- Iteration 9 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(0) ""
string(6) "string"
-- Iteration 10 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) " "
string(6) "string"
-- Iteration 11 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) " "
string(6) "string"
-- Iteration 12 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) "10"
string(6) "string"
-- Iteration 13 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) "10"
string(6) "string"
-- Iteration 14 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(8) "10string"
string(6) "string"
-- Iteration 15 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(8) "10string"
string(6) "string"
-- Iteration 16 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) "1"
string(6) "string"
-- Iteration 17 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) "-1"
string(6) "string"
-- Iteration 18 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(3) "1e2"
string(6) "string"
-- Iteration 19 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) " 1"
string(6) "string"
-- Iteration 20 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(22) "2974394749328742328432"
string(6) "string"
-- Iteration 21 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "-1e-2"
string(6) "string"
-- Iteration 22 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(1) "1"
string(6) "string"
-- Iteration 23 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) "-1"
string(6) "string"
-- Iteration 24 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(3) "1e2"
string(6) "string"
-- Iteration 25 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(2) " 1"
string(6) "string"
-- Iteration 26 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(22) "2974394749328742328432"
string(6) "string"
-- Iteration 27 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "-1e-2"
string(6) "string"
-- Iteration 28 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(4) "0xff"
string(6) "string"
-- Iteration 29 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(4) "0x55"
string(6) "string"
-- Iteration 30 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "0XA55"
string(6) "string"
-- Iteration 31 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "0X123"
string(6) "string"
-- Iteration 32 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(4) "0123"
string(6) "string"
-- Iteration 33 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(4) "0123"
string(6) "string"
-- Iteration 34 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "-0123"
string(6) "string"
-- Iteration 35 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "+0123"
string(6) "string"
-- Iteration 36 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "-0123"
string(6) "string"
-- Iteration 37 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(5) "+0123"
string(6) "string"
-- Iteration 38 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(8) "-0x80001"
string(6) "string"
-- Iteration 39 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(8) "+0x80001"
string(6) "string"
-- Iteration 40 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(10) "-0x80001.5"
string(6) "string"
-- Iteration 41 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(9) "0x80001.5"
string(6) "string"
-- Iteration 42 --
string(6) "string"
2: settype(): Cannot convert to resource type
bool(false)
string(12) "@$%#$%^$%^&^"
string(6) "string"
-- Iteration 43 --
string(5) "array"
2: settype(): Cannot convert to resource type
bool(false)
array(0) {
}
string(5) "array"
-- Iteration 44 --
string(5) "array"
2: settype(): Cannot convert to resource type
bool(false)
array(1) {
[0]=>
NULL
}
string(5) "array"
-- Iteration 45 --
string(5) "array"
2: settype(): Cannot convert to resource type
bool(false)
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
string(5) "array"
-- Iteration 46 --
string(5) "array"
2: settype(): Cannot convert to resource type
bool(false)
array(4) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(5) "three"
["four"]=>
int(4)
}
string(5) "array"
-- Iteration 47 --
string(5) "array"
2: settype(): Cannot convert to resource type
bool(false)
array(3) {
[0]=>
float(1.5)
[1]=>
float(2.4)
[2]=>
float(6500000)
}
string(5) "array"
-- Iteration 48 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-2147483648)
string(6) "double"
-- Iteration 49 --
string(7) "integer"
2: settype(): Cannot convert to resource type
bool(false)
int(2147483647)
string(7) "integer"
-- Iteration 50 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(2147483649)
string(6) "double"
-- Iteration 51 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(1232147483649)
string(6) "double"
-- Iteration 52 --
string(7) "integer"
2: settype(): Cannot convert to resource type
bool(false)
int(85)
string(7) "integer"
-- Iteration 53 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(1058513956921)
string(6) "double"
-- Iteration 54 --
string(7) "integer"
2: settype(): Cannot convert to resource type
bool(false)
int(-21903)
string(7) "integer"
-- Iteration 55 --
string(7) "integer"
2: settype(): Cannot convert to resource type
bool(false)
int(365)
string(7) "integer"
-- Iteration 56 --
string(7) "integer"
2: settype(): Cannot convert to resource type
bool(false)
int(-365)
string(7) "integer"
-- Iteration 57 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(80561044571754)
string(6) "double"
-- Iteration 58 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(100000)
string(6) "double"
-- Iteration 59 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-100000)
string(6) "double"
-- Iteration 60 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(100000)
string(6) "double"
-- Iteration 61 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-100000)
string(6) "double"
-- Iteration 62 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-1.5)
string(6) "double"
-- Iteration 63 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(0.5)
string(6) "double"
-- Iteration 64 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-0.5)
string(6) "double"
-- Iteration 65 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(500000)
string(6) "double"
-- Iteration 66 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-500000)
string(6) "double"
-- Iteration 67 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-5.0E-7)
string(6) "double"
-- Iteration 68 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(500000)
string(6) "double"
-- Iteration 69 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-500000)
string(6) "double"
-- Iteration 70 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(512000)
string(6) "double"
-- Iteration 71 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-512000)
string(6) "double"
-- Iteration 72 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(5.12E-7)
string(6) "double"
-- Iteration 73 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(5.12E-7)
string(6) "double"
-- Iteration 74 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(512000)
string(6) "double"
-- Iteration 75 --
string(6) "double"
2: settype(): Cannot convert to resource type
bool(false)
float(-512000)
string(6) "double"
-- Iteration 76 --
string(6) "object"
2: settype(): Cannot convert to resource type
bool(false)
object(point)#1 (2) {
["x"]=>
NULL
["y"]=>
NULL
}
string(6) "object"
-- Iteration 77 --
string(6) "object"
2: settype(): Cannot convert to resource type
bool(false)
object(point)#2 (2) {
["x"]=>
float(2.5)
["y"]=>
float(40.5)
}
string(6) "object"
-- Iteration 78 --
string(6) "object"
2: settype(): Cannot convert to resource type
bool(false)
object(point)#3 (2) {
["x"]=>
int(0)
["y"]=>
int(0)
}
string(6) "object"
-- Iteration 79 --
string(4) "NULL"
2: settype(): Cannot convert to resource type
bool(false)
NULL
string(4) "NULL"
-- Iteration 80 --
string(4) "NULL"
2: settype(): Cannot convert to resource type
bool(false)
NULL
string(4) "NULL"
Done

View file

@ -0,0 +1,840 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to array type.
Set type of the data to "array" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to array type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
/* test conversion to array type */
$type = "array";
echo "\n*** Testing gettype() & settype() functions : usage variations ***\n";
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to null
var_dump( settype($var, $type) );
// dump the converted data
var_dump( $var );
// check the new type after conversion
var_dump( gettype($var) );
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing gettype() & settype() functions : usage variations ***
-- Setting type of data to array --
-- Iteration 1 --
string(4) "NULL"
bool(true)
array(0) {
}
string(5) "array"
-- Iteration 2 --
string(7) "boolean"
bool(true)
array(1) {
[0]=>
bool(false)
}
string(5) "array"
-- Iteration 3 --
string(7) "boolean"
bool(true)
array(1) {
[0]=>
bool(true)
}
string(5) "array"
-- Iteration 4 --
string(7) "boolean"
bool(true)
array(1) {
[0]=>
bool(true)
}
string(5) "array"
-- Iteration 5 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) "ÿ"
}
string(5) "array"
-- Iteration 6 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) "f"
}
string(5) "array"
-- Iteration 7 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) "
3"
}
string(5) "array"
-- Iteration 8 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(0) ""
}
string(5) "array"
-- Iteration 9 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(0) ""
}
string(5) "array"
-- Iteration 10 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) " "
}
string(5) "array"
-- Iteration 11 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) " "
}
string(5) "array"
-- Iteration 12 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) "10"
}
string(5) "array"
-- Iteration 13 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) "10"
}
string(5) "array"
-- Iteration 14 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(8) "10string"
}
string(5) "array"
-- Iteration 15 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(8) "10string"
}
string(5) "array"
-- Iteration 16 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) "1"
}
string(5) "array"
-- Iteration 17 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) "-1"
}
string(5) "array"
-- Iteration 18 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(3) "1e2"
}
string(5) "array"
-- Iteration 19 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) " 1"
}
string(5) "array"
-- Iteration 20 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(22) "2974394749328742328432"
}
string(5) "array"
-- Iteration 21 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "-1e-2"
}
string(5) "array"
-- Iteration 22 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(1) "1"
}
string(5) "array"
-- Iteration 23 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) "-1"
}
string(5) "array"
-- Iteration 24 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(3) "1e2"
}
string(5) "array"
-- Iteration 25 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(2) " 1"
}
string(5) "array"
-- Iteration 26 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(22) "2974394749328742328432"
}
string(5) "array"
-- Iteration 27 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "-1e-2"
}
string(5) "array"
-- Iteration 28 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(4) "0xff"
}
string(5) "array"
-- Iteration 29 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(4) "0x55"
}
string(5) "array"
-- Iteration 30 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "0XA55"
}
string(5) "array"
-- Iteration 31 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "0X123"
}
string(5) "array"
-- Iteration 32 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(4) "0123"
}
string(5) "array"
-- Iteration 33 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(4) "0123"
}
string(5) "array"
-- Iteration 34 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "-0123"
}
string(5) "array"
-- Iteration 35 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "+0123"
}
string(5) "array"
-- Iteration 36 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "-0123"
}
string(5) "array"
-- Iteration 37 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(5) "+0123"
}
string(5) "array"
-- Iteration 38 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(8) "-0x80001"
}
string(5) "array"
-- Iteration 39 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(8) "+0x80001"
}
string(5) "array"
-- Iteration 40 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(10) "-0x80001.5"
}
string(5) "array"
-- Iteration 41 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(9) "0x80001.5"
}
string(5) "array"
-- Iteration 42 --
string(6) "string"
bool(true)
array(1) {
[0]=>
string(12) "@$%#$%^$%^&^"
}
string(5) "array"
-- Iteration 43 --
string(5) "array"
bool(true)
array(0) {
}
string(5) "array"
-- Iteration 44 --
string(5) "array"
bool(true)
array(1) {
[0]=>
NULL
}
string(5) "array"
-- Iteration 45 --
string(5) "array"
bool(true)
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
string(5) "array"
-- Iteration 46 --
string(5) "array"
bool(true)
array(4) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(5) "three"
["four"]=>
int(4)
}
string(5) "array"
-- Iteration 47 --
string(5) "array"
bool(true)
array(3) {
[0]=>
float(1.5)
[1]=>
float(2.4)
[2]=>
float(6500000)
}
string(5) "array"
-- Iteration 48 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-2147483648)
}
string(5) "array"
-- Iteration 49 --
string(7) "integer"
bool(true)
array(1) {
[0]=>
int(2147483647)
}
string(5) "array"
-- Iteration 50 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(2147483649)
}
string(5) "array"
-- Iteration 51 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(1232147483649)
}
string(5) "array"
-- Iteration 52 --
string(7) "integer"
bool(true)
array(1) {
[0]=>
int(85)
}
string(5) "array"
-- Iteration 53 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(1058513956921)
}
string(5) "array"
-- Iteration 54 --
string(7) "integer"
bool(true)
array(1) {
[0]=>
int(-21903)
}
string(5) "array"
-- Iteration 55 --
string(7) "integer"
bool(true)
array(1) {
[0]=>
int(365)
}
string(5) "array"
-- Iteration 56 --
string(7) "integer"
bool(true)
array(1) {
[0]=>
int(-365)
}
string(5) "array"
-- Iteration 57 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(80561044571754)
}
string(5) "array"
-- Iteration 58 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(100000)
}
string(5) "array"
-- Iteration 59 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-100000)
}
string(5) "array"
-- Iteration 60 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(100000)
}
string(5) "array"
-- Iteration 61 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-100000)
}
string(5) "array"
-- Iteration 62 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-1.5)
}
string(5) "array"
-- Iteration 63 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(0.5)
}
string(5) "array"
-- Iteration 64 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-0.5)
}
string(5) "array"
-- Iteration 65 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(500000)
}
string(5) "array"
-- Iteration 66 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-500000)
}
string(5) "array"
-- Iteration 67 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-5.0E-7)
}
string(5) "array"
-- Iteration 68 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(500000)
}
string(5) "array"
-- Iteration 69 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-500000)
}
string(5) "array"
-- Iteration 70 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(512000)
}
string(5) "array"
-- Iteration 71 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-512000)
}
string(5) "array"
-- Iteration 72 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(5.12E-7)
}
string(5) "array"
-- Iteration 73 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(5.12E-7)
}
string(5) "array"
-- Iteration 74 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(512000)
}
string(5) "array"
-- Iteration 75 --
string(6) "double"
bool(true)
array(1) {
[0]=>
float(-512000)
}
string(5) "array"
-- Iteration 76 --
string(6) "object"
bool(true)
array(2) {
["x"]=>
NULL
["y"]=>
NULL
}
string(5) "array"
-- Iteration 77 --
string(6) "object"
bool(true)
array(2) {
["x"]=>
float(2.5)
["y"]=>
float(40.5)
}
string(5) "array"
-- Iteration 78 --
string(6) "object"
bool(true)
array(2) {
["x"]=>
int(0)
["y"]=>
int(0)
}
string(5) "array"
-- Iteration 79 --
string(4) "NULL"
bool(true)
array(0) {
}
string(5) "array"
-- Iteration 80 --
string(4) "NULL"
bool(true)
array(0) {
}
string(5) "array"
Done

View file

@ -0,0 +1,838 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to object type.
Set type of the data to "object" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to object type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
/* test conversion to object type */
$type = "object";
echo "\n*** Testing gettype() & settype() functions : usage variations ***\n";
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to null
var_dump( settype($var, $type) );
// dump the converted data
var_dump( $var );
// check the new type after conversion
var_dump( gettype($var) );
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing gettype() & settype() functions : usage variations ***
-- Setting type of data to object --
-- Iteration 1 --
string(4) "NULL"
bool(true)
object(stdClass)#4 (0) {
}
string(6) "object"
-- Iteration 2 --
string(7) "boolean"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
bool(false)
}
string(6) "object"
-- Iteration 3 --
string(7) "boolean"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
bool(true)
}
string(6) "object"
-- Iteration 4 --
string(7) "boolean"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
bool(true)
}
string(6) "object"
-- Iteration 5 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) "ÿ"
}
string(6) "object"
-- Iteration 6 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) "f"
}
string(6) "object"
-- Iteration 7 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) "
3"
}
string(6) "object"
-- Iteration 8 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(0) ""
}
string(6) "object"
-- Iteration 9 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(0) ""
}
string(6) "object"
-- Iteration 10 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) " "
}
string(6) "object"
-- Iteration 11 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) " "
}
string(6) "object"
-- Iteration 12 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) "10"
}
string(6) "object"
-- Iteration 13 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) "10"
}
string(6) "object"
-- Iteration 14 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(8) "10string"
}
string(6) "object"
-- Iteration 15 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(8) "10string"
}
string(6) "object"
-- Iteration 16 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) "1"
}
string(6) "object"
-- Iteration 17 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) "-1"
}
string(6) "object"
-- Iteration 18 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(3) "1e2"
}
string(6) "object"
-- Iteration 19 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) " 1"
}
string(6) "object"
-- Iteration 20 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(22) "2974394749328742328432"
}
string(6) "object"
-- Iteration 21 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "-1e-2"
}
string(6) "object"
-- Iteration 22 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(1) "1"
}
string(6) "object"
-- Iteration 23 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) "-1"
}
string(6) "object"
-- Iteration 24 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(3) "1e2"
}
string(6) "object"
-- Iteration 25 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(2) " 1"
}
string(6) "object"
-- Iteration 26 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(22) "2974394749328742328432"
}
string(6) "object"
-- Iteration 27 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "-1e-2"
}
string(6) "object"
-- Iteration 28 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(4) "0xff"
}
string(6) "object"
-- Iteration 29 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(4) "0x55"
}
string(6) "object"
-- Iteration 30 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "0XA55"
}
string(6) "object"
-- Iteration 31 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "0X123"
}
string(6) "object"
-- Iteration 32 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(4) "0123"
}
string(6) "object"
-- Iteration 33 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(4) "0123"
}
string(6) "object"
-- Iteration 34 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "-0123"
}
string(6) "object"
-- Iteration 35 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "+0123"
}
string(6) "object"
-- Iteration 36 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "-0123"
}
string(6) "object"
-- Iteration 37 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(5) "+0123"
}
string(6) "object"
-- Iteration 38 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(8) "-0x80001"
}
string(6) "object"
-- Iteration 39 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(8) "+0x80001"
}
string(6) "object"
-- Iteration 40 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(10) "-0x80001.5"
}
string(6) "object"
-- Iteration 41 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(9) "0x80001.5"
}
string(6) "object"
-- Iteration 42 --
string(6) "string"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
string(12) "@$%#$%^$%^&^"
}
string(6) "object"
-- Iteration 43 --
string(5) "array"
bool(true)
object(stdClass)#4 (0) {
}
string(6) "object"
-- Iteration 44 --
string(5) "array"
bool(true)
object(stdClass)#4 (1) {
[0]=>
NULL
}
string(6) "object"
-- Iteration 45 --
string(5) "array"
bool(true)
object(stdClass)#4 (4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
string(6) "object"
-- Iteration 46 --
string(5) "array"
bool(true)
object(stdClass)#4 (4) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(5) "three"
["four"]=>
int(4)
}
string(6) "object"
-- Iteration 47 --
string(5) "array"
bool(true)
object(stdClass)#4 (3) {
[0]=>
float(1.5)
[1]=>
float(2.4)
[2]=>
float(6500000)
}
string(6) "object"
-- Iteration 48 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-2147483648)
}
string(6) "object"
-- Iteration 49 --
string(7) "integer"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
int(2147483647)
}
string(6) "object"
-- Iteration 50 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(2147483649)
}
string(6) "object"
-- Iteration 51 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(1232147483649)
}
string(6) "object"
-- Iteration 52 --
string(7) "integer"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
int(85)
}
string(6) "object"
-- Iteration 53 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(1058513956921)
}
string(6) "object"
-- Iteration 54 --
string(7) "integer"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
int(-21903)
}
string(6) "object"
-- Iteration 55 --
string(7) "integer"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
int(365)
}
string(6) "object"
-- Iteration 56 --
string(7) "integer"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
int(-365)
}
string(6) "object"
-- Iteration 57 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(80561044571754)
}
string(6) "object"
-- Iteration 58 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(100000)
}
string(6) "object"
-- Iteration 59 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-100000)
}
string(6) "object"
-- Iteration 60 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(100000)
}
string(6) "object"
-- Iteration 61 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-100000)
}
string(6) "object"
-- Iteration 62 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-1.5)
}
string(6) "object"
-- Iteration 63 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(0.5)
}
string(6) "object"
-- Iteration 64 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-0.5)
}
string(6) "object"
-- Iteration 65 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(500000)
}
string(6) "object"
-- Iteration 66 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-500000)
}
string(6) "object"
-- Iteration 67 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-5.0E-7)
}
string(6) "object"
-- Iteration 68 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(500000)
}
string(6) "object"
-- Iteration 69 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-500000)
}
string(6) "object"
-- Iteration 70 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(512000)
}
string(6) "object"
-- Iteration 71 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-512000)
}
string(6) "object"
-- Iteration 72 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(5.12E-7)
}
string(6) "object"
-- Iteration 73 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(5.12E-7)
}
string(6) "object"
-- Iteration 74 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(512000)
}
string(6) "object"
-- Iteration 75 --
string(6) "double"
bool(true)
object(stdClass)#4 (1) {
["scalar"]=>
float(-512000)
}
string(6) "object"
-- Iteration 76 --
string(6) "object"
bool(true)
object(point)#1 (2) {
["x"]=>
NULL
["y"]=>
NULL
}
string(6) "object"
-- Iteration 77 --
string(6) "object"
bool(true)
object(point)#2 (2) {
["x"]=>
float(2.5)
["y"]=>
float(40.5)
}
string(6) "object"
-- Iteration 78 --
string(6) "object"
bool(true)
object(point)#3 (2) {
["x"]=>
int(0)
["y"]=>
int(0)
}
string(6) "object"
-- Iteration 79 --
string(4) "NULL"
bool(true)
object(stdClass)#4 (0) {
}
string(6) "object"
-- Iteration 80 --
string(4) "NULL"
bool(true)
object(stdClass)#4 (0) {
}
string(6) "object"
Done

View file

@ -0,0 +1,589 @@
--TEST--
Test gettype() & settype() functions : usage variations
--FILE--
<?php
/* Prototype: string gettype ( mixed $var );
Description: Returns the type of the PHP variable var
Prototype: bool settype ( mixed &$var, string $type );
Description: Set the type of variable var to type
*/
/* Test usage variation of gettype() and settype() functions:
settype() to string type.
Set type of the data to "string" and verify using gettype
Following are performed in the listed sequence:
get the current type of the variable
set the type of the variable to string type
dump the variable to see its new data
get the new type of the variable
*/
/* function to handle catchable errors */
function foo($errno, $errstr, $errfile, $errline) {
// var_dump($errstr);
// print error no and error string
echo "$errno: $errstr\n";
}
//set the error handler, this is required as
// settype() would fail with catachable fatal error
set_error_handler("foo");
$var1 = "another string";
$var2 = array(2,3,4);
// a variable which is unset
$unset_var = 10.5;
unset( $unset_var );
class point
{
var $x;
var $y;
function point($x, $y) {
$this->x = $x;
$this->y = $y;
}
function __toString() {
return "ObjectPoint";
}
}
$var_values = array (
/* nulls */
null,
/* boolean */
FALSE,
TRUE,
true,
/* strings */
"\xFF",
"\x66",
"\0123",
"",
'',
" ",
' ',
/* numerics in the form of string */
'10',
"10",
"10string",
'10string',
"1",
"-1",
"1e2",
" 1",
"2974394749328742328432",
"-1e-2",
'1',
'-1',
'1e2',
' 1',
'2974394749328742328432',
'-1e-2',
"0xff",
'0x55',
'0XA55',
'0X123',
"0123",
'0123',
"-0123",
"+0123",
'-0123',
'+0123',
"-0x80001", // invalid numerics as its prefix with sign or have decimal points
"+0x80001",
"-0x80001.5",
"0x80001.5",
"@$%#$%^$%^&^",
/* arrays */
array(),
array(NULL),
array(1,2,3,4),
array(1 => "one", 2 => "two", "3" => "three", "four" => 4),
array(1.5, 2.4, 6.5e6),
/* integers */
-2147483648, // max -ne int value
2147483647,
2147483649,
1232147483649,
0x55,
0xF674593039, // a hex value > than max int
-0X558F,
0555,
-0555,
02224242434343152, // an octal value > than max int
/* floats */
1e5,
-1e5,
1E5,
-1E5,
-1.5,
.5,
-.5,
.5e6,
-.5e6,
-.5e-6,
.5e+6,
-.5e+6,
.512E6,
-.512E6,
.512E-6,
+.512E-6,
.512E+6,
-.512E+6,
new point(NULL, NULL),
new point(2.5, 40.5),
new point(0, 0),
/* undefined/unset vars */
$unset_var,
$undef_var
);
/* test conversion to string type */
$type = "string";
echo "\n*** Testing gettype() & settype() functions : usage variations ***\n";
echo "\n-- Setting type of data to $type --\n";
$loop_count = 1;
foreach ($var_values as $var) {
echo "-- Iteration $loop_count --\n"; $loop_count++;
// get the current data type
var_dump( gettype($var) );
// convert it to null
var_dump( settype($var, $type) );
// dump the converted data
var_dump( $var );
// check the new type after conversion
var_dump( gettype($var) );
}
echo "Done\n";
?>
--EXPECTF--
8: Undefined variable: unset_var
8: Undefined variable: undef_var
*** Testing gettype() & settype() functions : usage variations ***
-- Setting type of data to string --
-- Iteration 1 --
string(4) "NULL"
bool(true)
string(0) ""
string(6) "string"
-- Iteration 2 --
string(7) "boolean"
bool(true)
string(0) ""
string(6) "string"
-- Iteration 3 --
string(7) "boolean"
bool(true)
string(1) "1"
string(6) "string"
-- Iteration 4 --
string(7) "boolean"
bool(true)
string(1) "1"
string(6) "string"
-- Iteration 5 --
string(6) "string"
bool(true)
string(1) "ÿ"
string(6) "string"
-- Iteration 6 --
string(6) "string"
bool(true)
string(1) "f"
string(6) "string"
-- Iteration 7 --
string(6) "string"
bool(true)
string(2) "
3"
string(6) "string"
-- Iteration 8 --
string(6) "string"
bool(true)
string(0) ""
string(6) "string"
-- Iteration 9 --
string(6) "string"
bool(true)
string(0) ""
string(6) "string"
-- Iteration 10 --
string(6) "string"
bool(true)
string(1) " "
string(6) "string"
-- Iteration 11 --
string(6) "string"
bool(true)
string(1) " "
string(6) "string"
-- Iteration 12 --
string(6) "string"
bool(true)
string(2) "10"
string(6) "string"
-- Iteration 13 --
string(6) "string"
bool(true)
string(2) "10"
string(6) "string"
-- Iteration 14 --
string(6) "string"
bool(true)
string(8) "10string"
string(6) "string"
-- Iteration 15 --
string(6) "string"
bool(true)
string(8) "10string"
string(6) "string"
-- Iteration 16 --
string(6) "string"
bool(true)
string(1) "1"
string(6) "string"
-- Iteration 17 --
string(6) "string"
bool(true)
string(2) "-1"
string(6) "string"
-- Iteration 18 --
string(6) "string"
bool(true)
string(3) "1e2"
string(6) "string"
-- Iteration 19 --
string(6) "string"
bool(true)
string(2) " 1"
string(6) "string"
-- Iteration 20 --
string(6) "string"
bool(true)
string(22) "2974394749328742328432"
string(6) "string"
-- Iteration 21 --
string(6) "string"
bool(true)
string(5) "-1e-2"
string(6) "string"
-- Iteration 22 --
string(6) "string"
bool(true)
string(1) "1"
string(6) "string"
-- Iteration 23 --
string(6) "string"
bool(true)
string(2) "-1"
string(6) "string"
-- Iteration 24 --
string(6) "string"
bool(true)
string(3) "1e2"
string(6) "string"
-- Iteration 25 --
string(6) "string"
bool(true)
string(2) " 1"
string(6) "string"
-- Iteration 26 --
string(6) "string"
bool(true)
string(22) "2974394749328742328432"
string(6) "string"
-- Iteration 27 --
string(6) "string"
bool(true)
string(5) "-1e-2"
string(6) "string"
-- Iteration 28 --
string(6) "string"
bool(true)
string(4) "0xff"
string(6) "string"
-- Iteration 29 --
string(6) "string"
bool(true)
string(4) "0x55"
string(6) "string"
-- Iteration 30 --
string(6) "string"
bool(true)
string(5) "0XA55"
string(6) "string"
-- Iteration 31 --
string(6) "string"
bool(true)
string(5) "0X123"
string(6) "string"
-- Iteration 32 --
string(6) "string"
bool(true)
string(4) "0123"
string(6) "string"
-- Iteration 33 --
string(6) "string"
bool(true)
string(4) "0123"
string(6) "string"
-- Iteration 34 --
string(6) "string"
bool(true)
string(5) "-0123"
string(6) "string"
-- Iteration 35 --
string(6) "string"
bool(true)
string(5) "+0123"
string(6) "string"
-- Iteration 36 --
string(6) "string"
bool(true)
string(5) "-0123"
string(6) "string"
-- Iteration 37 --
string(6) "string"
bool(true)
string(5) "+0123"
string(6) "string"
-- Iteration 38 --
string(6) "string"
bool(true)
string(8) "-0x80001"
string(6) "string"
-- Iteration 39 --
string(6) "string"
bool(true)
string(8) "+0x80001"
string(6) "string"
-- Iteration 40 --
string(6) "string"
bool(true)
string(10) "-0x80001.5"
string(6) "string"
-- Iteration 41 --
string(6) "string"
bool(true)
string(9) "0x80001.5"
string(6) "string"
-- Iteration 42 --
string(6) "string"
bool(true)
string(12) "@$%#$%^$%^&^"
string(6) "string"
-- Iteration 43 --
string(5) "array"
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 44 --
string(5) "array"
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 45 --
string(5) "array"
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 46 --
string(5) "array"
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 47 --
string(5) "array"
8: Array to string conversion
bool(true)
string(5) "Array"
string(6) "string"
-- Iteration 48 --
string(6) "double"
bool(true)
string(11) "-2147483648"
string(6) "string"
-- Iteration 49 --
string(7) "integer"
bool(true)
string(10) "2147483647"
string(6) "string"
-- Iteration 50 --
string(6) "double"
bool(true)
string(10) "2147483649"
string(6) "string"
-- Iteration 51 --
string(6) "double"
bool(true)
string(13) "1232147483649"
string(6) "string"
-- Iteration 52 --
string(7) "integer"
bool(true)
string(2) "85"
string(6) "string"
-- Iteration 53 --
string(6) "double"
bool(true)
string(13) "1058513956921"
string(6) "string"
-- Iteration 54 --
string(7) "integer"
bool(true)
string(6) "-21903"
string(6) "string"
-- Iteration 55 --
string(7) "integer"
bool(true)
string(3) "365"
string(6) "string"
-- Iteration 56 --
string(7) "integer"
bool(true)
string(4) "-365"
string(6) "string"
-- Iteration 57 --
string(6) "double"
bool(true)
string(14) "80561044571754"
string(6) "string"
-- Iteration 58 --
string(6) "double"
bool(true)
string(6) "100000"
string(6) "string"
-- Iteration 59 --
string(6) "double"
bool(true)
string(7) "-100000"
string(6) "string"
-- Iteration 60 --
string(6) "double"
bool(true)
string(6) "100000"
string(6) "string"
-- Iteration 61 --
string(6) "double"
bool(true)
string(7) "-100000"
string(6) "string"
-- Iteration 62 --
string(6) "double"
bool(true)
string(4) "-1.5"
string(6) "string"
-- Iteration 63 --
string(6) "double"
bool(true)
string(3) "0.5"
string(6) "string"
-- Iteration 64 --
string(6) "double"
bool(true)
string(4) "-0.5"
string(6) "string"
-- Iteration 65 --
string(6) "double"
bool(true)
string(6) "500000"
string(6) "string"
-- Iteration 66 --
string(6) "double"
bool(true)
string(7) "-500000"
string(6) "string"
-- Iteration 67 --
string(6) "double"
bool(true)
string(7) "-5.0E-7"
string(6) "string"
-- Iteration 68 --
string(6) "double"
bool(true)
string(6) "500000"
string(6) "string"
-- Iteration 69 --
string(6) "double"
bool(true)
string(7) "-500000"
string(6) "string"
-- Iteration 70 --
string(6) "double"
bool(true)
string(6) "512000"
string(6) "string"
-- Iteration 71 --
string(6) "double"
bool(true)
string(7) "-512000"
string(6) "string"
-- Iteration 72 --
string(6) "double"
bool(true)
string(7) "5.12E-7"
string(6) "string"
-- Iteration 73 --
string(6) "double"
bool(true)
string(7) "5.12E-7"
string(6) "string"
-- Iteration 74 --
string(6) "double"
bool(true)
string(6) "512000"
string(6) "string"
-- Iteration 75 --
string(6) "double"
bool(true)
string(7) "-512000"
string(6) "string"
-- Iteration 76 --
string(6) "object"
bool(true)
string(11) "ObjectPoint"
string(6) "string"
-- Iteration 77 --
string(6) "object"
bool(true)
string(11) "ObjectPoint"
string(6) "string"
-- Iteration 78 --
string(6) "object"
bool(true)
string(11) "ObjectPoint"
string(6) "string"
-- Iteration 79 --
string(4) "NULL"
bool(true)
string(0) ""
string(6) "string"
-- Iteration 80 --
string(4) "NULL"
bool(true)
string(0) ""
string(6) "string"
Done