019.phpt 26 KB

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