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