019.phpt 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  1. --TEST--
  2. Test unset(), empty() and isset() functions
  3. --FILE--
  4. <?php
  5. echo "*** Testing unset(), empty() & isset() with scalar variables ***\n";
  6. // testing scalar variables
  7. $scalar_variables = array(
  8. 0,
  9. 1,
  10. +1
  11. -1,
  12. 0x55,
  13. -0xFA,
  14. 0123,
  15. -0563,
  16. 0.0,
  17. 1e5,
  18. 1E-5,
  19. -1.5e5,
  20. +5.6,
  21. "",
  22. '',
  23. " ",
  24. ' ',
  25. "string",
  26. "123",
  27. "0",
  28. "ture",
  29. "FALSE",
  30. "NULL",
  31. "null",
  32. true,
  33. false,
  34. TRUE,
  35. FALSE
  36. );
  37. $loop_counter = 1;
  38. foreach ($scalar_variables as $scalar_var) {
  39. $set_var = 10; // this variable to use with isset
  40. echo "-- Iteration $loop_counter --\n"; $loop_counter++;
  41. // checking with isset before unsetting, expected: bool(true)
  42. var_dump( isset($scalar_var) );
  43. var_dump( isset($scalar_var, $set_var) );
  44. // checking if the var is empty, expected: bool(false) on most
  45. // except "", 0, "0", NULL, FALSE
  46. var_dump( empty($scalar_var) );
  47. // destroy the variable using unset
  48. unset( $scalar_var );
  49. // dump and see if its destroyed, expcted: NULL
  50. var_dump( $scalar_var );
  51. // check using isset to see if unset, expected: bool(false)
  52. var_dump( isset($scalar_var) );
  53. var_dump( isset($scalar_var, $set_var) );
  54. // empty to check if empty, expecting bool(true)
  55. var_dump( empty($scalar_var) );
  56. // isset() with two args, one arg only unset, expected: bool(false)
  57. var_dump( isset($scalar_var, $set_var) );
  58. // isset() with two args, both args already unset, expected: bool(false);
  59. unset($set_var);
  60. var_dump( isset($scalar_var, $set_var) );
  61. }
  62. echo "\n*** Testing unset(), empty() & isset() with arrays ***\n";
  63. $array_variables = array(
  64. array(),
  65. array(NULL),
  66. array(0),
  67. array("0"),
  68. array(""),
  69. array(1,2,3,4),
  70. array(1.4,2.5,5.6),
  71. array(1 => "One", 2 => "two"),
  72. array("Name" => "Jack", "Age" => "30"),
  73. array(1,2, "One" => "1", 2 => "two", ""=>"empty", "" => '')
  74. );
  75. $outer_loop_counter = 1;
  76. foreach ($array_variables as $array_var) {
  77. echo "--- Outerloop Iteration $outer_loop_counter ---\n";
  78. // check the isset and unset on non existing key
  79. $var = 1; // a var which is defined
  80. // try to unset the element which is non-existent
  81. unset($array_var['non_existent']);
  82. // check using isset() & empty() on a non_existent element in the array
  83. var_dump( isset($array_var['non_existent']) );
  84. var_dump( isset($array_var['non_existent'], $var) );
  85. var_dump( isset($array_var['non_existent'], $array_var['none']) );
  86. var_dump( empty($array_var['non_existent']) );
  87. // testing empty and isset on arrays
  88. var_dump( empty($array_var) ); // expecting bool(false), except: array(), which is considered empty
  89. var_dump( isset($array_var) ); // expecting bool(true), except: array(), which is not set
  90. // get the keys of the $array_var
  91. $keys = array_keys($array_var);
  92. // unset each element in the array and see the working of unset, isset & empty
  93. $inner_loop_counter = 1;
  94. foreach ($keys as $key_value) {
  95. echo "-- Innerloop Iteration $inner_loop_counter of Outerloop Iteration $outer_loop_counter --\n";
  96. $inner_loop_counter++;
  97. // unset the element
  98. unset($array_var[$key_value]);
  99. // dump the array after element was unset
  100. var_dump($array_var);
  101. // check using isset for the element that was unset
  102. var_dump( isset($array_var[$key_val]) ); // expected: bool(false)
  103. // calling isset with more args
  104. var_dump( isset($array_var[$key_val], $array_var) ); //expected: bool(false)
  105. // calling empty, expected bool(true)
  106. var_dump( empty($array_var[$key_val]) );
  107. // dump the array to see that that array did not get modified
  108. // because of using isset, empty and unset on its element
  109. var_dump($array_var);
  110. }
  111. $outer_loop_counter++;
  112. // unset the whole array
  113. unset($array_var);
  114. // dump the array to see its unset
  115. var_dump($array_var);
  116. // use isset to see that array is not set
  117. var_dump( isset($array_var) ); //expected: bool(false)
  118. var_dump( isset($array_var, $array_var[$key_val]) ); // expected: bool(false)
  119. // empty() to see if the array is empty
  120. var_dump( empty($array_var) ); // expected: bool(true)
  121. }
  122. echo "\n*** Testing unset(), empty() & isset() with resource variables ***\n";
  123. $fp = fopen(__FILE__, "r");
  124. $dfp = opendir( __DIR__ );
  125. $resources = array (
  126. $fp,
  127. $dfp
  128. );
  129. $loop_counter = 1;
  130. foreach ($resources as $resource) {
  131. $temp_var = 10;
  132. echo "-- Iteration $loop_counter --\n"; $loop_counter++;
  133. //dump the resource first
  134. var_dump($resource);
  135. // check using isset() and empty()
  136. var_dump( isset($resource) ); // expected: bool(true)
  137. var_dump( empty($resource) ); // expected: bool(false)
  138. // call isset() with two args, both set
  139. var_dump( isset($resource, $temp_var) ); // expected: bool(true)
  140. // dump the resource to see using isset() and empty () had no effect on it
  141. var_dump($resource);
  142. // unset the resource
  143. unset($resource);
  144. // check using isset() and empty()
  145. var_dump( isset($resource) ); // expected: bool(flase)
  146. var_dump( empty($resource) ); // expected: bool(true)
  147. // call isset() with two args, but one set
  148. var_dump( isset($resource, $temp_var) ); // expected: bool(false)
  149. // uset the temp_var
  150. unset($temp_var);
  151. // now the isset() with both the args as unset
  152. var_dump( isset($resource, $temp_var) ); // expected: bool(false);
  153. // dump the resource to see if there any effect on it
  154. var_dump($resource);
  155. }
  156. // unset and dump the array containing all the resources to see that
  157. // unset works correctly
  158. unset($resources);
  159. var_dump($resources);
  160. var_dump( isset($resources) ); //expected: bool(false)
  161. var_dump( empty($resources) ); // expected: bool(true)
  162. echo "\n*** Testing unset(), empty() & isset() with objects ***\n";
  163. class Point
  164. {
  165. var $x;
  166. var $y;
  167. var $lable;
  168. function __construct($x, $y) {
  169. $this->x = $x;
  170. $this->y = $y;
  171. }
  172. function setLable($lable) {
  173. $this->lable = $lable;
  174. }
  175. function testPoint() {
  176. echo "\nPoint::testPoint() called\n";
  177. }
  178. }
  179. $point1 = new Point(30,40);
  180. // use unset/empty/isset to check the object
  181. var_dump($point1); // dump the object
  182. // check the object and member that is not set
  183. var_dump( isset($point1) ); // expected: bool(true)
  184. var_dump( empty($point1) ); // expected: bool(false)
  185. var_dump( isset($point1->$lable) ); //expected: bool(flase)
  186. var_dump( empty($point1->$lable) ); //expected: bool(true)
  187. //set the member variable lable and check
  188. $point1->setLable("Point1");
  189. var_dump( isset($point1->$lable) ); //expected: bool(true)
  190. var_dump( empty($point1->$lable) ); //expected: bool(false)
  191. // dump the object to see that obj was not harmed
  192. // because of the usage of the isset & empty
  193. var_dump($point1);
  194. //unset a member and check
  195. unset($point1->x);
  196. // dump the point to see that variable was unset
  197. var_dump($point1);
  198. var_dump( isset($point1->x) ); // expected: bool(false)
  199. var_dump( empty($point1->x) ); // expected: bool(true)
  200. // unset all members and check
  201. unset($point1->y);
  202. unset($point1->lable);
  203. // dump the object to check that all variables are unset
  204. var_dump($point1);
  205. var_dump( isset($point1) ); // expected: bool(ture)
  206. var_dump( empty($point1) ); // expected: bool(false)
  207. //unset the object and check
  208. unset($point1);
  209. var_dump( isset($point1) ); // expected: bool(false)
  210. var_dump( empty($point1) ); // expected: bool(true)
  211. // dump to see that object is unset
  212. var_dump($point1);
  213. // try isset/unset/empty on a member function
  214. $point2 = new Point(5,6);
  215. var_dump( isset($point2->testPoint) );
  216. var_dump( empty($point2->testPoint) );
  217. unset($point2->testPoint);
  218. var_dump( isset($point2->testPoint) );
  219. var_dump( empty($point2->testPoint) );
  220. // use get_class_methods to see effect if any
  221. var_dump( get_class_methods($point2) );
  222. // dump the object to see the effect, none expected
  223. var_dump($point2);
  224. /* testing variation in operation for isset(), empty() & unset().
  225. Note: Most of the variation for function unset() is testing by a
  226. set of testcases named "Zend/tests/unset_cv??.phpt", only
  227. variation not tested are attempted here */
  228. echo "\n*** Testing possible variation in operation for isset(), empty() & unset() ***\n";
  229. /* unset() variation1: checking unset on static variable inside a function.
  230. * unset() destroys the variable only in the context of the rest of a function
  231. * Following calls will restore the previous value of a variable.
  232. */
  233. echo "\n** Testing unset() variation 1: unset on static variable inside a function **\n";
  234. function test_unset1() {
  235. static $static_var;
  236. // increment the value of the static. this change is in function context
  237. $static_var ++;
  238. echo "value of static_var before unset: $static_var\n";
  239. // check using isset and empty
  240. var_dump( isset($static_var) );
  241. var_dump( empty($static_var) );
  242. // unset the static var
  243. unset($static_var);
  244. echo "value of static_var after unset: $static_var\n";
  245. // check using isset and empty
  246. var_dump( isset($static_var) );
  247. var_dump( empty($static_var) );
  248. // assign a value to static var
  249. $static_var = 20;
  250. echo "value of static_var after new assignment: $static_var\n";
  251. }
  252. // call the functiont
  253. test_unset1();
  254. test_unset1();
  255. test_unset1();
  256. echo "\n** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **\n";
  257. /* unset() variation2: Pass by reference
  258. * If a variable that is PASSED BY REFERENCE is unset() inside of a function,
  259. * only the local variable is destroyed. The variable in the calling environment
  260. * will retain the same value as before unset() was called.
  261. */
  262. function test_unset2( &$ref_val ) {
  263. // unset the variable passed
  264. unset($ref_val);
  265. // check using isset and empty to confirm
  266. var_dump( isset($ref_val) );
  267. var_dump( empty($ref_val) );
  268. // set the value ot a new one
  269. $ref_val = "new value by ref";
  270. }
  271. $value = "value";
  272. var_dump($value);
  273. test_unset2($value);
  274. var_dump($value);
  275. echo "\n** Testing unset() variation 3: unset on a global variable inside of a function **\n";
  276. /* unset() variation2: unset on a global variable inside a function
  277. * If a globalized variable is unset() inside of a function, only the
  278. * local variable is destroyed. The variable in the calling environment
  279. * will retain the same value as before unset() was called.
  280. */
  281. $global_var = 10;
  282. function test_unset3() {
  283. global $global_var;
  284. // check the $global_var using isset and empty
  285. var_dump( isset($global_var) );
  286. var_dump( empty($global_var) );
  287. // unset the global var
  288. unset($global_var);
  289. // check the $global_var using isset and empty
  290. var_dump( isset($global_var) );
  291. var_dump( empty($global_var) );
  292. }
  293. var_dump($global_var);
  294. test_unset3();
  295. var_dump($global_var);
  296. //Note: No error conditions relating to passing arguments can be tested
  297. // because these are not functions but statements, it will result in syntax error.
  298. ?>
  299. --EXPECTF--
  300. *** Testing unset(), empty() & isset() with scalar variables ***
  301. -- Iteration 1 --
  302. bool(true)
  303. bool(true)
  304. bool(true)
  305. Warning: Undefined variable $scalar_var in %s on line %d
  306. NULL
  307. bool(false)
  308. bool(false)
  309. bool(true)
  310. bool(false)
  311. bool(false)
  312. -- Iteration 2 --
  313. bool(true)
  314. bool(true)
  315. bool(false)
  316. Warning: Undefined variable $scalar_var in %s on line %d
  317. NULL
  318. bool(false)
  319. bool(false)
  320. bool(true)
  321. bool(false)
  322. bool(false)
  323. -- Iteration 3 --
  324. bool(true)
  325. bool(true)
  326. bool(true)
  327. Warning: Undefined variable $scalar_var in %s on line %d
  328. NULL
  329. bool(false)
  330. bool(false)
  331. bool(true)
  332. bool(false)
  333. bool(false)
  334. -- Iteration 4 --
  335. bool(true)
  336. bool(true)
  337. bool(false)
  338. Warning: Undefined variable $scalar_var in %s on line %d
  339. NULL
  340. bool(false)
  341. bool(false)
  342. bool(true)
  343. bool(false)
  344. bool(false)
  345. -- Iteration 5 --
  346. bool(true)
  347. bool(true)
  348. bool(false)
  349. Warning: Undefined variable $scalar_var in %s on line %d
  350. NULL
  351. bool(false)
  352. bool(false)
  353. bool(true)
  354. bool(false)
  355. bool(false)
  356. -- Iteration 6 --
  357. bool(true)
  358. bool(true)
  359. bool(false)
  360. Warning: Undefined variable $scalar_var in %s on line %d
  361. NULL
  362. bool(false)
  363. bool(false)
  364. bool(true)
  365. bool(false)
  366. bool(false)
  367. -- Iteration 7 --
  368. bool(true)
  369. bool(true)
  370. bool(false)
  371. Warning: Undefined variable $scalar_var in %s on line %d
  372. NULL
  373. bool(false)
  374. bool(false)
  375. bool(true)
  376. bool(false)
  377. bool(false)
  378. -- Iteration 8 --
  379. bool(true)
  380. bool(true)
  381. bool(true)
  382. Warning: Undefined variable $scalar_var in %s on line %d
  383. NULL
  384. bool(false)
  385. bool(false)
  386. bool(true)
  387. bool(false)
  388. bool(false)
  389. -- Iteration 9 --
  390. bool(true)
  391. bool(true)
  392. bool(false)
  393. Warning: Undefined variable $scalar_var in %s on line %d
  394. NULL
  395. bool(false)
  396. bool(false)
  397. bool(true)
  398. bool(false)
  399. bool(false)
  400. -- Iteration 10 --
  401. bool(true)
  402. bool(true)
  403. bool(false)
  404. Warning: Undefined variable $scalar_var in %s on line %d
  405. NULL
  406. bool(false)
  407. bool(false)
  408. bool(true)
  409. bool(false)
  410. bool(false)
  411. -- Iteration 11 --
  412. bool(true)
  413. bool(true)
  414. bool(false)
  415. Warning: Undefined variable $scalar_var in %s on line %d
  416. NULL
  417. bool(false)
  418. bool(false)
  419. bool(true)
  420. bool(false)
  421. bool(false)
  422. -- Iteration 12 --
  423. bool(true)
  424. bool(true)
  425. bool(false)
  426. Warning: Undefined variable $scalar_var in %s on line %d
  427. NULL
  428. bool(false)
  429. bool(false)
  430. bool(true)
  431. bool(false)
  432. bool(false)
  433. -- Iteration 13 --
  434. bool(true)
  435. bool(true)
  436. bool(true)
  437. Warning: Undefined variable $scalar_var in %s on line %d
  438. NULL
  439. bool(false)
  440. bool(false)
  441. bool(true)
  442. bool(false)
  443. bool(false)
  444. -- Iteration 14 --
  445. bool(true)
  446. bool(true)
  447. bool(true)
  448. Warning: Undefined variable $scalar_var in %s on line %d
  449. NULL
  450. bool(false)
  451. bool(false)
  452. bool(true)
  453. bool(false)
  454. bool(false)
  455. -- Iteration 15 --
  456. bool(true)
  457. bool(true)
  458. bool(false)
  459. Warning: Undefined variable $scalar_var in %s on line %d
  460. NULL
  461. bool(false)
  462. bool(false)
  463. bool(true)
  464. bool(false)
  465. bool(false)
  466. -- Iteration 16 --
  467. bool(true)
  468. bool(true)
  469. bool(false)
  470. Warning: Undefined variable $scalar_var in %s on line %d
  471. NULL
  472. bool(false)
  473. bool(false)
  474. bool(true)
  475. bool(false)
  476. bool(false)
  477. -- Iteration 17 --
  478. bool(true)
  479. bool(true)
  480. bool(false)
  481. Warning: Undefined variable $scalar_var in %s on line %d
  482. NULL
  483. bool(false)
  484. bool(false)
  485. bool(true)
  486. bool(false)
  487. bool(false)
  488. -- Iteration 18 --
  489. bool(true)
  490. bool(true)
  491. bool(false)
  492. Warning: Undefined variable $scalar_var in %s on line %d
  493. NULL
  494. bool(false)
  495. bool(false)
  496. bool(true)
  497. bool(false)
  498. bool(false)
  499. -- Iteration 19 --
  500. bool(true)
  501. bool(true)
  502. bool(true)
  503. Warning: Undefined variable $scalar_var in %s on line %d
  504. NULL
  505. bool(false)
  506. bool(false)
  507. bool(true)
  508. bool(false)
  509. bool(false)
  510. -- Iteration 20 --
  511. bool(true)
  512. bool(true)
  513. bool(false)
  514. Warning: Undefined variable $scalar_var in %s on line %d
  515. NULL
  516. bool(false)
  517. bool(false)
  518. bool(true)
  519. bool(false)
  520. bool(false)
  521. -- Iteration 21 --
  522. bool(true)
  523. bool(true)
  524. bool(false)
  525. Warning: Undefined variable $scalar_var in %s on line %d
  526. NULL
  527. bool(false)
  528. bool(false)
  529. bool(true)
  530. bool(false)
  531. bool(false)
  532. -- Iteration 22 --
  533. bool(true)
  534. bool(true)
  535. bool(false)
  536. Warning: Undefined variable $scalar_var in %s on line %d
  537. NULL
  538. bool(false)
  539. bool(false)
  540. bool(true)
  541. bool(false)
  542. bool(false)
  543. -- Iteration 23 --
  544. bool(true)
  545. bool(true)
  546. bool(false)
  547. Warning: Undefined variable $scalar_var in %s on line %d
  548. NULL
  549. bool(false)
  550. bool(false)
  551. bool(true)
  552. bool(false)
  553. bool(false)
  554. -- Iteration 24 --
  555. bool(true)
  556. bool(true)
  557. bool(false)
  558. Warning: Undefined variable $scalar_var in %s on line %d
  559. NULL
  560. bool(false)
  561. bool(false)
  562. bool(true)
  563. bool(false)
  564. bool(false)
  565. -- Iteration 25 --
  566. bool(true)
  567. bool(true)
  568. bool(true)
  569. Warning: Undefined variable $scalar_var in %s on line %d
  570. NULL
  571. bool(false)
  572. bool(false)
  573. bool(true)
  574. bool(false)
  575. bool(false)
  576. -- Iteration 26 --
  577. bool(true)
  578. bool(true)
  579. bool(false)
  580. Warning: Undefined variable $scalar_var in %s on line %d
  581. NULL
  582. bool(false)
  583. bool(false)
  584. bool(true)
  585. bool(false)
  586. bool(false)
  587. -- Iteration 27 --
  588. bool(true)
  589. bool(true)
  590. bool(true)
  591. Warning: Undefined variable $scalar_var in %s on line %d
  592. NULL
  593. bool(false)
  594. bool(false)
  595. bool(true)
  596. bool(false)
  597. bool(false)
  598. *** Testing unset(), empty() & isset() with arrays ***
  599. --- Outerloop Iteration 1 ---
  600. bool(false)
  601. bool(false)
  602. bool(false)
  603. bool(true)
  604. bool(true)
  605. bool(true)
  606. Warning: Undefined variable $array_var in %s on line %d
  607. NULL
  608. bool(false)
  609. bool(false)
  610. bool(true)
  611. --- Outerloop Iteration 2 ---
  612. bool(false)
  613. bool(false)
  614. bool(false)
  615. bool(true)
  616. bool(false)
  617. bool(true)
  618. -- Innerloop Iteration 1 of Outerloop Iteration 2 --
  619. array(0) {
  620. }
  621. Warning: Undefined variable $key_val in %s on line %d
  622. bool(false)
  623. Warning: Undefined variable $key_val in %s on line %d
  624. bool(false)
  625. Warning: Undefined variable $key_val in %s on line %d
  626. bool(true)
  627. array(0) {
  628. }
  629. Warning: Undefined variable $array_var in %s on line %d
  630. NULL
  631. bool(false)
  632. bool(false)
  633. bool(true)
  634. --- Outerloop Iteration 3 ---
  635. bool(false)
  636. bool(false)
  637. bool(false)
  638. bool(true)
  639. bool(false)
  640. bool(true)
  641. -- Innerloop Iteration 1 of Outerloop Iteration 3 --
  642. array(0) {
  643. }
  644. Warning: Undefined variable $key_val in %s on line %d
  645. bool(false)
  646. Warning: Undefined variable $key_val in %s on line %d
  647. bool(false)
  648. Warning: Undefined variable $key_val in %s on line %d
  649. bool(true)
  650. array(0) {
  651. }
  652. Warning: Undefined variable $array_var in %s on line %d
  653. NULL
  654. bool(false)
  655. bool(false)
  656. bool(true)
  657. --- Outerloop Iteration 4 ---
  658. bool(false)
  659. bool(false)
  660. bool(false)
  661. bool(true)
  662. bool(false)
  663. bool(true)
  664. -- Innerloop Iteration 1 of Outerloop Iteration 4 --
  665. array(0) {
  666. }
  667. Warning: Undefined variable $key_val in %s on line %d
  668. bool(false)
  669. Warning: Undefined variable $key_val in %s on line %d
  670. bool(false)
  671. Warning: Undefined variable $key_val in %s on line %d
  672. bool(true)
  673. array(0) {
  674. }
  675. Warning: Undefined variable $array_var in %s on line %d
  676. NULL
  677. bool(false)
  678. bool(false)
  679. bool(true)
  680. --- Outerloop Iteration 5 ---
  681. bool(false)
  682. bool(false)
  683. bool(false)
  684. bool(true)
  685. bool(false)
  686. bool(true)
  687. -- Innerloop Iteration 1 of Outerloop Iteration 5 --
  688. array(0) {
  689. }
  690. Warning: Undefined variable $key_val in %s on line %d
  691. bool(false)
  692. Warning: Undefined variable $key_val in %s on line %d
  693. bool(false)
  694. Warning: Undefined variable $key_val in %s on line %d
  695. bool(true)
  696. array(0) {
  697. }
  698. Warning: Undefined variable $array_var in %s on line %d
  699. NULL
  700. bool(false)
  701. bool(false)
  702. bool(true)
  703. --- Outerloop Iteration 6 ---
  704. bool(false)
  705. bool(false)
  706. bool(false)
  707. bool(true)
  708. bool(false)
  709. bool(true)
  710. -- Innerloop Iteration 1 of Outerloop Iteration 6 --
  711. array(3) {
  712. [1]=>
  713. int(2)
  714. [2]=>
  715. int(3)
  716. [3]=>
  717. int(4)
  718. }
  719. Warning: Undefined variable $key_val in %s on line %d
  720. bool(false)
  721. Warning: Undefined variable $key_val in %s on line %d
  722. bool(false)
  723. Warning: Undefined variable $key_val in %s on line %d
  724. bool(true)
  725. array(3) {
  726. [1]=>
  727. int(2)
  728. [2]=>
  729. int(3)
  730. [3]=>
  731. int(4)
  732. }
  733. -- Innerloop Iteration 2 of Outerloop Iteration 6 --
  734. array(2) {
  735. [2]=>
  736. int(3)
  737. [3]=>
  738. int(4)
  739. }
  740. Warning: Undefined variable $key_val in %s on line %d
  741. bool(false)
  742. Warning: Undefined variable $key_val in %s on line %d
  743. bool(false)
  744. Warning: Undefined variable $key_val in %s on line %d
  745. bool(true)
  746. array(2) {
  747. [2]=>
  748. int(3)
  749. [3]=>
  750. int(4)
  751. }
  752. -- Innerloop Iteration 3 of Outerloop Iteration 6 --
  753. array(1) {
  754. [3]=>
  755. int(4)
  756. }
  757. Warning: Undefined variable $key_val in %s on line %d
  758. bool(false)
  759. Warning: Undefined variable $key_val in %s on line %d
  760. bool(false)
  761. Warning: Undefined variable $key_val in %s on line %d
  762. bool(true)
  763. array(1) {
  764. [3]=>
  765. int(4)
  766. }
  767. -- Innerloop Iteration 4 of Outerloop Iteration 6 --
  768. array(0) {
  769. }
  770. Warning: Undefined variable $key_val in %s on line %d
  771. bool(false)
  772. Warning: Undefined variable $key_val in %s on line %d
  773. bool(false)
  774. Warning: Undefined variable $key_val in %s on line %d
  775. bool(true)
  776. array(0) {
  777. }
  778. Warning: Undefined variable $array_var in %s on line %d
  779. NULL
  780. bool(false)
  781. bool(false)
  782. bool(true)
  783. --- Outerloop Iteration 7 ---
  784. bool(false)
  785. bool(false)
  786. bool(false)
  787. bool(true)
  788. bool(false)
  789. bool(true)
  790. -- Innerloop Iteration 1 of Outerloop Iteration 7 --
  791. array(2) {
  792. [1]=>
  793. float(2.5)
  794. [2]=>
  795. float(5.6)
  796. }
  797. Warning: Undefined variable $key_val in %s on line %d
  798. bool(false)
  799. Warning: Undefined variable $key_val in %s on line %d
  800. bool(false)
  801. Warning: Undefined variable $key_val in %s on line %d
  802. bool(true)
  803. array(2) {
  804. [1]=>
  805. float(2.5)
  806. [2]=>
  807. float(5.6)
  808. }
  809. -- Innerloop Iteration 2 of Outerloop Iteration 7 --
  810. array(1) {
  811. [2]=>
  812. float(5.6)
  813. }
  814. Warning: Undefined variable $key_val in %s on line %d
  815. bool(false)
  816. Warning: Undefined variable $key_val in %s on line %d
  817. bool(false)
  818. Warning: Undefined variable $key_val in %s on line %d
  819. bool(true)
  820. array(1) {
  821. [2]=>
  822. float(5.6)
  823. }
  824. -- Innerloop Iteration 3 of Outerloop Iteration 7 --
  825. array(0) {
  826. }
  827. Warning: Undefined variable $key_val in %s on line %d
  828. bool(false)
  829. Warning: Undefined variable $key_val in %s on line %d
  830. bool(false)
  831. Warning: Undefined variable $key_val in %s on line %d
  832. bool(true)
  833. array(0) {
  834. }
  835. Warning: Undefined variable $array_var in %s on line %d
  836. NULL
  837. bool(false)
  838. bool(false)
  839. bool(true)
  840. --- Outerloop Iteration 8 ---
  841. bool(false)
  842. bool(false)
  843. bool(false)
  844. bool(true)
  845. bool(false)
  846. bool(true)
  847. -- Innerloop Iteration 1 of Outerloop Iteration 8 --
  848. array(1) {
  849. [2]=>
  850. string(3) "two"
  851. }
  852. Warning: Undefined variable $key_val in %s on line %d
  853. bool(false)
  854. Warning: Undefined variable $key_val in %s on line %d
  855. bool(false)
  856. Warning: Undefined variable $key_val in %s on line %d
  857. bool(true)
  858. array(1) {
  859. [2]=>
  860. string(3) "two"
  861. }
  862. -- Innerloop Iteration 2 of Outerloop Iteration 8 --
  863. array(0) {
  864. }
  865. Warning: Undefined variable $key_val in %s on line %d
  866. bool(false)
  867. Warning: Undefined variable $key_val in %s on line %d
  868. bool(false)
  869. Warning: Undefined variable $key_val in %s on line %d
  870. bool(true)
  871. array(0) {
  872. }
  873. Warning: Undefined variable $array_var in %s on line %d
  874. NULL
  875. bool(false)
  876. bool(false)
  877. bool(true)
  878. --- Outerloop Iteration 9 ---
  879. bool(false)
  880. bool(false)
  881. bool(false)
  882. bool(true)
  883. bool(false)
  884. bool(true)
  885. -- Innerloop Iteration 1 of Outerloop Iteration 9 --
  886. array(1) {
  887. ["Age"]=>
  888. string(2) "30"
  889. }
  890. Warning: Undefined variable $key_val in %s on line %d
  891. bool(false)
  892. Warning: Undefined variable $key_val in %s on line %d
  893. bool(false)
  894. Warning: Undefined variable $key_val in %s on line %d
  895. bool(true)
  896. array(1) {
  897. ["Age"]=>
  898. string(2) "30"
  899. }
  900. -- Innerloop Iteration 2 of Outerloop Iteration 9 --
  901. array(0) {
  902. }
  903. Warning: Undefined variable $key_val in %s on line %d
  904. bool(false)
  905. Warning: Undefined variable $key_val in %s on line %d
  906. bool(false)
  907. Warning: Undefined variable $key_val in %s on line %d
  908. bool(true)
  909. array(0) {
  910. }
  911. Warning: Undefined variable $array_var in %s on line %d
  912. NULL
  913. bool(false)
  914. bool(false)
  915. bool(true)
  916. --- Outerloop Iteration 10 ---
  917. bool(false)
  918. bool(false)
  919. bool(false)
  920. bool(true)
  921. bool(false)
  922. bool(true)
  923. -- Innerloop Iteration 1 of Outerloop Iteration 10 --
  924. array(4) {
  925. [1]=>
  926. int(2)
  927. ["One"]=>
  928. string(1) "1"
  929. [2]=>
  930. string(3) "two"
  931. [""]=>
  932. string(0) ""
  933. }
  934. Warning: Undefined variable $key_val in %s on line %d
  935. bool(true)
  936. Warning: Undefined variable $key_val in %s on line %d
  937. bool(true)
  938. Warning: Undefined variable $key_val in %s on line %d
  939. bool(true)
  940. array(4) {
  941. [1]=>
  942. int(2)
  943. ["One"]=>
  944. string(1) "1"
  945. [2]=>
  946. string(3) "two"
  947. [""]=>
  948. string(0) ""
  949. }
  950. -- Innerloop Iteration 2 of Outerloop Iteration 10 --
  951. array(3) {
  952. ["One"]=>
  953. string(1) "1"
  954. [2]=>
  955. string(3) "two"
  956. [""]=>
  957. string(0) ""
  958. }
  959. Warning: Undefined variable $key_val in %s on line %d
  960. bool(true)
  961. Warning: Undefined variable $key_val in %s on line %d
  962. bool(true)
  963. Warning: Undefined variable $key_val in %s on line %d
  964. bool(true)
  965. array(3) {
  966. ["One"]=>
  967. string(1) "1"
  968. [2]=>
  969. string(3) "two"
  970. [""]=>
  971. string(0) ""
  972. }
  973. -- Innerloop Iteration 3 of Outerloop Iteration 10 --
  974. array(2) {
  975. [2]=>
  976. string(3) "two"
  977. [""]=>
  978. string(0) ""
  979. }
  980. Warning: Undefined variable $key_val in %s on line %d
  981. bool(true)
  982. Warning: Undefined variable $key_val in %s on line %d
  983. bool(true)
  984. Warning: Undefined variable $key_val in %s on line %d
  985. bool(true)
  986. array(2) {
  987. [2]=>
  988. string(3) "two"
  989. [""]=>
  990. string(0) ""
  991. }
  992. -- Innerloop Iteration 4 of Outerloop Iteration 10 --
  993. array(1) {
  994. [""]=>
  995. string(0) ""
  996. }
  997. Warning: Undefined variable $key_val in %s on line %d
  998. bool(true)
  999. Warning: Undefined variable $key_val in %s on line %d
  1000. bool(true)
  1001. Warning: Undefined variable $key_val in %s on line %d
  1002. bool(true)
  1003. array(1) {
  1004. [""]=>
  1005. string(0) ""
  1006. }
  1007. -- Innerloop Iteration 5 of Outerloop Iteration 10 --
  1008. array(0) {
  1009. }
  1010. Warning: Undefined variable $key_val in %s on line %d
  1011. bool(false)
  1012. Warning: Undefined variable $key_val in %s on line %d
  1013. bool(false)
  1014. Warning: Undefined variable $key_val in %s on line %d
  1015. bool(true)
  1016. array(0) {
  1017. }
  1018. Warning: Undefined variable $array_var in %s on line %d
  1019. NULL
  1020. bool(false)
  1021. bool(false)
  1022. bool(true)
  1023. *** Testing unset(), empty() & isset() with resource variables ***
  1024. -- Iteration 1 --
  1025. resource(%d) of type (stream)
  1026. bool(true)
  1027. bool(false)
  1028. bool(true)
  1029. resource(%d) of type (stream)
  1030. bool(false)
  1031. bool(true)
  1032. bool(false)
  1033. bool(false)
  1034. Warning: Undefined variable $resource in %s on line %d
  1035. NULL
  1036. -- Iteration 2 --
  1037. resource(%d) of type (stream)
  1038. bool(true)
  1039. bool(false)
  1040. bool(true)
  1041. resource(%d) of type (stream)
  1042. bool(false)
  1043. bool(true)
  1044. bool(false)
  1045. bool(false)
  1046. Warning: Undefined variable $resource in %s on line %d
  1047. NULL
  1048. Warning: Undefined variable $resources in %s on line %d
  1049. NULL
  1050. bool(false)
  1051. bool(true)
  1052. *** Testing unset(), empty() & isset() with objects ***
  1053. object(Point)#%d (3) {
  1054. ["x"]=>
  1055. int(30)
  1056. ["y"]=>
  1057. int(40)
  1058. ["lable"]=>
  1059. NULL
  1060. }
  1061. bool(true)
  1062. bool(false)
  1063. Warning: Undefined variable $lable in %s on line %d
  1064. bool(false)
  1065. Warning: Undefined variable $lable in %s on line %d
  1066. bool(true)
  1067. Warning: Undefined variable $lable in %s on line %d
  1068. bool(false)
  1069. Warning: Undefined variable $lable in %s on line %d
  1070. bool(true)
  1071. object(Point)#%d (3) {
  1072. ["x"]=>
  1073. int(30)
  1074. ["y"]=>
  1075. int(40)
  1076. ["lable"]=>
  1077. string(6) "Point1"
  1078. }
  1079. object(Point)#%d (2) {
  1080. ["y"]=>
  1081. int(40)
  1082. ["lable"]=>
  1083. string(6) "Point1"
  1084. }
  1085. bool(false)
  1086. bool(true)
  1087. object(Point)#%d (0) {
  1088. }
  1089. bool(true)
  1090. bool(false)
  1091. bool(false)
  1092. bool(true)
  1093. Warning: Undefined variable $point1 in %s on line %d
  1094. NULL
  1095. bool(false)
  1096. bool(true)
  1097. bool(false)
  1098. bool(true)
  1099. array(3) {
  1100. [0]=>
  1101. string(11) "__construct"
  1102. [1]=>
  1103. string(8) "setLable"
  1104. [2]=>
  1105. string(9) "testPoint"
  1106. }
  1107. object(Point)#%d (3) {
  1108. ["x"]=>
  1109. int(5)
  1110. ["y"]=>
  1111. int(6)
  1112. ["lable"]=>
  1113. NULL
  1114. }
  1115. *** Testing possible variation in operation for isset(), empty() & unset() ***
  1116. ** Testing unset() variation 1: unset on static variable inside a function **
  1117. value of static_var before unset: 1
  1118. bool(true)
  1119. bool(false)
  1120. Warning: Undefined variable $static_var in %s on line %d
  1121. value of static_var after unset:
  1122. bool(false)
  1123. bool(true)
  1124. value of static_var after new assignment: 20
  1125. value of static_var before unset: 2
  1126. bool(true)
  1127. bool(false)
  1128. Warning: Undefined variable $static_var in %s on line %d
  1129. value of static_var after unset:
  1130. bool(false)
  1131. bool(true)
  1132. value of static_var after new assignment: 20
  1133. value of static_var before unset: 3
  1134. bool(true)
  1135. bool(false)
  1136. Warning: Undefined variable $static_var in %s on line %d
  1137. value of static_var after unset:
  1138. bool(false)
  1139. bool(true)
  1140. value of static_var after new assignment: 20
  1141. ** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **
  1142. string(5) "value"
  1143. bool(false)
  1144. bool(true)
  1145. string(5) "value"
  1146. ** Testing unset() variation 3: unset on a global variable inside of a function **
  1147. int(10)
  1148. bool(true)
  1149. bool(false)
  1150. bool(false)
  1151. bool(true)
  1152. int(10)