1--TEST--
2Test is_resource() function : basic functionality
3--FILE--
4<?php
5echo "*** Testing is_resource() : basic functionality ***\n";
6
7class Hello {
8  public function SayHello($arg) {
9    echo "Hello\n";
10  }
11}
12
13
14$vars = array(
15    false,
16    true,
17    10,
18    10.5,
19    "Helo World",
20    array(1,2,3,4,5),
21    NULL,
22    new Hello());
23
24$types = array(
25    "bool=false",
26    "bool=true",
27    "integer",
28    "double",
29    "string",
30    "array",
31    "NULL",
32    "object");
33
34echo "\nNon-resource type cases\n";
35
36for ($i=0; $i < count($vars); $i++) {
37    if (is_resource($vars[$i])) {
38        echo $types[$i]. " test returns TRUE\n";
39    } else {
40        echo $types[$i]. " test returns FALSE\n";
41    }
42}
43
44$res = fopen(__FILE__, "r");
45echo "\nResource type..var_dump after file open returns\n";
46var_dump($res);
47echo "Resource type..after file open  is_resource() returns";
48if (is_resource($res)) {
49    echo " TRUE\n";
50} else {
51    echo " FALSE\n";
52}
53
54fclose($res);
55echo "\nResource type..var_dump after file close returns\n";
56var_dump($res);
57echo "Resource type..after file close is_resource() returns";
58if (is_resource($res)) {
59    echo " TRUE\n";
60} else {
61    echo " FALSE\n";
62}
63
64
65?>
66--EXPECTF--
67*** Testing is_resource() : basic functionality ***
68
69Non-resource type cases
70bool=false test returns FALSE
71bool=true test returns FALSE
72integer test returns FALSE
73double test returns FALSE
74string test returns FALSE
75array test returns FALSE
76NULL test returns FALSE
77object test returns FALSE
78
79Resource type..var_dump after file open returns
80resource(%d) of type (%s)
81Resource type..after file open  is_resource() returns TRUE
82
83Resource type..var_dump after file close returns
84resource(%d) of type (Unknown)
85Resource type..after file close is_resource() returns FALSE
86