1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 |
- --TEST--
- Test unset(), empty() and isset() functions
- --FILE--
- <?php
- echo "*** Testing unset(), empty() & isset() with scalar variables ***\n";
- // testing scalar variables
- $scalar_variables = array(
- 0,
- 1,
- +1
- -1,
- 0x55,
- -0xFA,
- 0123,
- -0563,
- 0.0,
- 1e5,
- 1E-5,
- -1.5e5,
- +5.6,
- "",
- '',
- " ",
- ' ',
- "string",
- "123",
- "0",
- "ture",
- "FALSE",
- "NULL",
- "null",
- true,
- false,
- TRUE,
- FALSE
- );
- $loop_counter = 1;
- foreach ($scalar_variables as $scalar_var) {
- $set_var = 10; // this variable to use with isset
- echo "-- Iteration $loop_counter --\n"; $loop_counter++;
- // checking with isset before unsetting, expected: bool(true)
- var_dump( isset($scalar_var) );
- var_dump( isset($scalar_var, $set_var) );
- // checking if the var is empty, expected: bool(false) on most
- // except "", 0, "0", NULL, FALSE
- var_dump( empty($scalar_var) );
- // destroy the variable using unset
- unset( $scalar_var );
- // dump and see if its destroyed, expcted: NULL
- var_dump( $scalar_var );
- // check using isset to see if unset, expected: bool(false)
- var_dump( isset($scalar_var) );
- var_dump( isset($scalar_var, $set_var) );
- // empty to check if empty, expecting bool(true)
- var_dump( empty($scalar_var) );
- // isset() with two args, one arg only unset, expected: bool(false)
- var_dump( isset($scalar_var, $set_var) );
- // isset() with two args, both args already unset, expected: bool(false);
- unset($set_var);
- var_dump( isset($scalar_var, $set_var) );
- }
- echo "\n*** Testing unset(), empty() & isset() with arrays ***\n";
- $array_variables = array(
- array(),
- array(NULL),
- array(0),
- array("0"),
- array(""),
- array(1,2,3,4),
- array(1.4,2.5,5.6),
- array(1 => "One", 2 => "two"),
- array("Name" => "Jack", "Age" => "30"),
- array(1,2, "One" => "1", 2 => "two", ""=>"empty", "" => '')
- );
- $outer_loop_counter = 1;
- foreach ($array_variables as $array_var) {
- echo "--- Outerloop Iteration $outer_loop_counter ---\n";
- // check the isset and unset on non existing key
- $var = 1; // a var which is defined
- // try to unset the element which is non-existent
- unset($array_var['non_existent']);
- // check using isset() & empty() on a non_existent element in the array
- var_dump( isset($array_var['non_existent']) );
- var_dump( isset($array_var['non_existent'], $var) );
- var_dump( isset($array_var['non_existent'], $array_var['none']) );
- var_dump( empty($array_var['non_existent']) );
- // testing empty and isset on arrays
- var_dump( empty($array_var) ); // expecting bool(false), except: array(), which is considered empty
- var_dump( isset($array_var) ); // expecting bool(true), except: array(), which is not set
- // get the keys of the $array_var
- $keys = array_keys($array_var);
- // unset each element in the array and see the working of unset, isset & empty
- $inner_loop_counter = 1;
- foreach ($keys as $key_value) {
- echo "-- Innerloop Iteration $inner_loop_counter of Outerloop Iteration $outer_loop_counter --\n";
- $inner_loop_counter++;
- // unset the element
- unset($array_var[$key_value]);
- // dump the array after element was unset
- var_dump($array_var);
- // check using isset for the element that was unset
- var_dump( isset($array_var[$key_val]) ); // expected: bool(false)
- // calling isset with more args
- var_dump( isset($array_var[$key_val], $array_var) ); //expected: bool(false)
- // calling empty, expected bool(true)
- var_dump( empty($array_var[$key_val]) );
- // dump the array to see that that array did not get modified
- // because of using isset, empty and unset on its element
- var_dump($array_var);
- }
- $outer_loop_counter++;
- // unset the whole array
- unset($array_var);
- // dump the array to see its unset
- var_dump($array_var);
- // use isset to see that array is not set
- var_dump( isset($array_var) ); //expected: bool(false)
- var_dump( isset($array_var, $array_var[$key_val]) ); // expected: bool(false)
- // empty() to see if the array is empty
- var_dump( empty($array_var) ); // expected: bool(true)
- }
- echo "\n*** Testing unset(), empty() & isset() with resource variables ***\n";
- $fp = fopen(__FILE__, "r");
- $dfp = opendir( __DIR__ );
- $resources = array (
- $fp,
- $dfp
- );
- $loop_counter = 1;
- foreach ($resources as $resource) {
- $temp_var = 10;
- echo "-- Iteration $loop_counter --\n"; $loop_counter++;
- //dump the resource first
- var_dump($resource);
- // check using isset() and empty()
- var_dump( isset($resource) ); // expected: bool(true)
- var_dump( empty($resource) ); // expected: bool(false)
- // call isset() with two args, both set
- var_dump( isset($resource, $temp_var) ); // expected: bool(true)
- // dump the resource to see using isset() and empty () had no effect on it
- var_dump($resource);
- // unset the resource
- unset($resource);
- // check using isset() and empty()
- var_dump( isset($resource) ); // expected: bool(flase)
- var_dump( empty($resource) ); // expected: bool(true)
- // call isset() with two args, but one set
- var_dump( isset($resource, $temp_var) ); // expected: bool(false)
- // uset the temp_var
- unset($temp_var);
- // now the isset() with both the args as unset
- var_dump( isset($resource, $temp_var) ); // expected: bool(false);
- // dump the resource to see if there any effect on it
- var_dump($resource);
- }
- // unset and dump the array containing all the resources to see that
- // unset works correctly
- unset($resources);
- var_dump($resources);
- var_dump( isset($resources) ); //expected: bool(false)
- var_dump( empty($resources) ); // expected: bool(true)
- echo "\n*** Testing unset(), empty() & isset() with objects ***\n";
- class Point
- {
- var $x;
- var $y;
- var $lable;
- function __construct($x, $y) {
- $this->x = $x;
- $this->y = $y;
- }
- function setLable($lable) {
- $this->lable = $lable;
- }
- function testPoint() {
- echo "\nPoint::testPoint() called\n";
- }
- }
- $point1 = new Point(30,40);
- // use unset/empty/isset to check the object
- var_dump($point1); // dump the object
- // check the object and member that is not set
- var_dump( isset($point1) ); // expected: bool(true)
- var_dump( empty($point1) ); // expected: bool(false)
- var_dump( isset($point1->$lable) ); //expected: bool(flase)
- var_dump( empty($point1->$lable) ); //expected: bool(true)
- //set the member variable lable and check
- $point1->setLable("Point1");
- var_dump( isset($point1->$lable) ); //expected: bool(true)
- var_dump( empty($point1->$lable) ); //expected: bool(false)
- // dump the object to see that obj was not harmed
- // because of the usage of the isset & empty
- var_dump($point1);
- //unset a member and check
- unset($point1->x);
- // dump the point to see that variable was unset
- var_dump($point1);
- var_dump( isset($point1->x) ); // expected: bool(false)
- var_dump( empty($point1->x) ); // expected: bool(true)
- // unset all members and check
- unset($point1->y);
- unset($point1->lable);
- // dump the object to check that all variables are unset
- var_dump($point1);
- var_dump( isset($point1) ); // expected: bool(ture)
- var_dump( empty($point1) ); // expected: bool(false)
- //unset the object and check
- unset($point1);
- var_dump( isset($point1) ); // expected: bool(false)
- var_dump( empty($point1) ); // expected: bool(true)
- // dump to see that object is unset
- var_dump($point1);
- // try isset/unset/empty on a member function
- $point2 = new Point(5,6);
- var_dump( isset($point2->testPoint) );
- var_dump( empty($point2->testPoint) );
- unset($point2->testPoint);
- var_dump( isset($point2->testPoint) );
- var_dump( empty($point2->testPoint) );
- // use get_class_methods to see effect if any
- var_dump( get_class_methods($point2) );
- // dump the object to see the effect, none expected
- var_dump($point2);
- /* testing variation in operation for isset(), empty() & unset().
- Note: Most of the variation for function unset() is testing by a
- set of testcases named "Zend/tests/unset_cv??.phpt", only
- variation not tested are attempted here */
- echo "\n*** Testing possible variation in operation for isset(), empty() & unset() ***\n";
- /* unset() variation1: checking unset on static variable inside a function.
- * unset() destroys the variable only in the context of the rest of a function
- * Following calls will restore the previous value of a variable.
- */
- echo "\n** Testing unset() variation 1: unset on static variable inside a function **\n";
- function test_unset1() {
- static $static_var;
- // increment the value of the static. this change is in function context
- $static_var ++;
- echo "value of static_var before unset: $static_var\n";
- // check using isset and empty
- var_dump( isset($static_var) );
- var_dump( empty($static_var) );
- // unset the static var
- unset($static_var);
- echo "value of static_var after unset: $static_var\n";
- // check using isset and empty
- var_dump( isset($static_var) );
- var_dump( empty($static_var) );
- // assign a value to static var
- $static_var = 20;
- echo "value of static_var after new assignment: $static_var\n";
- }
- // call the functiont
- test_unset1();
- test_unset1();
- test_unset1();
- echo "\n** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **\n";
- /* unset() variation2: Pass by reference
- * If a variable that is PASSED BY REFERENCE is unset() inside of a function,
- * only the local variable is destroyed. The variable in the calling environment
- * will retain the same value as before unset() was called.
- */
- function test_unset2( &$ref_val ) {
- // unset the variable passed
- unset($ref_val);
- // check using isset and empty to confirm
- var_dump( isset($ref_val) );
- var_dump( empty($ref_val) );
- // set the value ot a new one
- $ref_val = "new value by ref";
- }
- $value = "value";
- var_dump($value);
- test_unset2($value);
- var_dump($value);
- echo "\n** Testing unset() variation 3: unset on a global variable inside of a function **\n";
- /* unset() variation2: unset on a global variable inside a function
- * If a globalized variable is unset() inside of a function, only the
- * local variable is destroyed. The variable in the calling environment
- * will retain the same value as before unset() was called.
- */
- $global_var = 10;
- function test_unset3() {
- global $global_var;
- // check the $global_var using isset and empty
- var_dump( isset($global_var) );
- var_dump( empty($global_var) );
- // unset the global var
- unset($global_var);
- // check the $global_var using isset and empty
- var_dump( isset($global_var) );
- var_dump( empty($global_var) );
- }
- var_dump($global_var);
- test_unset3();
- var_dump($global_var);
- //Note: No error conditions relating to passing arguments can be tested
- // because these are not functions but statements, it will result in syntax error.
- ?>
- --EXPECTF--
- *** Testing unset(), empty() & isset() with scalar variables ***
- -- Iteration 1 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 2 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 3 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 4 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 5 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 6 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 7 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 8 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 9 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 10 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 11 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 12 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 13 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 14 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 15 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 16 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 17 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 18 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 19 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 20 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 21 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 22 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 23 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 24 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 25 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 26 --
- bool(true)
- bool(true)
- bool(false)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- -- Iteration 27 --
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $scalar_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- *** Testing unset(), empty() & isset() with arrays ***
- --- Outerloop Iteration 1 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(true)
- bool(true)
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 2 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 2 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 3 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 3 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 4 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 4 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 5 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 5 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 6 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 6 --
- array(3) {
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(3) {
- [1]=>
- int(2)
- [2]=>
- int(3)
- [3]=>
- int(4)
- }
- -- Innerloop Iteration 2 of Outerloop Iteration 6 --
- array(2) {
- [2]=>
- int(3)
- [3]=>
- int(4)
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(2) {
- [2]=>
- int(3)
- [3]=>
- int(4)
- }
- -- Innerloop Iteration 3 of Outerloop Iteration 6 --
- array(1) {
- [3]=>
- int(4)
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(1) {
- [3]=>
- int(4)
- }
- -- Innerloop Iteration 4 of Outerloop Iteration 6 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 7 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 7 --
- array(2) {
- [1]=>
- float(2.5)
- [2]=>
- float(5.6)
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(2) {
- [1]=>
- float(2.5)
- [2]=>
- float(5.6)
- }
- -- Innerloop Iteration 2 of Outerloop Iteration 7 --
- array(1) {
- [2]=>
- float(5.6)
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(1) {
- [2]=>
- float(5.6)
- }
- -- Innerloop Iteration 3 of Outerloop Iteration 7 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 8 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 8 --
- array(1) {
- [2]=>
- string(3) "two"
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(1) {
- [2]=>
- string(3) "two"
- }
- -- Innerloop Iteration 2 of Outerloop Iteration 8 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 9 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 9 --
- array(1) {
- ["Age"]=>
- string(2) "30"
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(1) {
- ["Age"]=>
- string(2) "30"
- }
- -- Innerloop Iteration 2 of Outerloop Iteration 9 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- --- Outerloop Iteration 10 ---
- bool(false)
- bool(false)
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- -- Innerloop Iteration 1 of Outerloop Iteration 10 --
- array(4) {
- [1]=>
- int(2)
- ["One"]=>
- string(1) "1"
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(4) {
- [1]=>
- int(2)
- ["One"]=>
- string(1) "1"
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- -- Innerloop Iteration 2 of Outerloop Iteration 10 --
- array(3) {
- ["One"]=>
- string(1) "1"
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(3) {
- ["One"]=>
- string(1) "1"
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- -- Innerloop Iteration 3 of Outerloop Iteration 10 --
- array(2) {
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(2) {
- [2]=>
- string(3) "two"
- [""]=>
- string(0) ""
- }
- -- Innerloop Iteration 4 of Outerloop Iteration 10 --
- array(1) {
- [""]=>
- string(0) ""
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(1) {
- [""]=>
- string(0) ""
- }
- -- Innerloop Iteration 5 of Outerloop Iteration 10 --
- array(0) {
- }
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(false)
- Warning: Undefined variable $key_val in %s on line %d
- bool(true)
- array(0) {
- }
- Warning: Undefined variable $array_var in %s on line %d
- NULL
- bool(false)
- bool(false)
- bool(true)
- *** Testing unset(), empty() & isset() with resource variables ***
- -- Iteration 1 --
- resource(%d) of type (stream)
- bool(true)
- bool(false)
- bool(true)
- resource(%d) of type (stream)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- Warning: Undefined variable $resource in %s on line %d
- NULL
- -- Iteration 2 --
- resource(%d) of type (stream)
- bool(true)
- bool(false)
- bool(true)
- resource(%d) of type (stream)
- bool(false)
- bool(true)
- bool(false)
- bool(false)
- Warning: Undefined variable $resource in %s on line %d
- NULL
- Warning: Undefined variable $resources in %s on line %d
- NULL
- bool(false)
- bool(true)
- *** Testing unset(), empty() & isset() with objects ***
- object(Point)#%d (3) {
- ["x"]=>
- int(30)
- ["y"]=>
- int(40)
- ["lable"]=>
- NULL
- }
- bool(true)
- bool(false)
- Warning: Undefined variable $lable in %s on line %d
- bool(false)
- Warning: Undefined variable $lable in %s on line %d
- bool(true)
- Warning: Undefined variable $lable in %s on line %d
- bool(false)
- Warning: Undefined variable $lable in %s on line %d
- bool(true)
- object(Point)#%d (3) {
- ["x"]=>
- int(30)
- ["y"]=>
- int(40)
- ["lable"]=>
- string(6) "Point1"
- }
- object(Point)#%d (2) {
- ["y"]=>
- int(40)
- ["lable"]=>
- string(6) "Point1"
- }
- bool(false)
- bool(true)
- object(Point)#%d (0) {
- }
- bool(true)
- bool(false)
- bool(false)
- bool(true)
- Warning: Undefined variable $point1 in %s on line %d
- NULL
- bool(false)
- bool(true)
- bool(false)
- bool(true)
- array(3) {
- [0]=>
- string(11) "__construct"
- [1]=>
- string(8) "setLable"
- [2]=>
- string(9) "testPoint"
- }
- object(Point)#%d (3) {
- ["x"]=>
- int(5)
- ["y"]=>
- int(6)
- ["lable"]=>
- NULL
- }
- *** Testing possible variation in operation for isset(), empty() & unset() ***
- ** Testing unset() variation 1: unset on static variable inside a function **
- value of static_var before unset: 1
- bool(true)
- bool(false)
- Warning: Undefined variable $static_var in %s on line %d
- value of static_var after unset:
- bool(false)
- bool(true)
- value of static_var after new assignment: 20
- value of static_var before unset: 2
- bool(true)
- bool(false)
- Warning: Undefined variable $static_var in %s on line %d
- value of static_var after unset:
- bool(false)
- bool(true)
- value of static_var after new assignment: 20
- value of static_var before unset: 3
- bool(true)
- bool(false)
- Warning: Undefined variable $static_var in %s on line %d
- value of static_var after unset:
- bool(false)
- bool(true)
- value of static_var after new assignment: 20
- ** Testing unset() variation 2: unset on a variable passed by ref. inside of a function **
- string(5) "value"
- bool(false)
- bool(true)
- string(5) "value"
- ** Testing unset() variation 3: unset on a global variable inside of a function **
- int(10)
- bool(true)
- bool(false)
- bool(false)
- bool(true)
- int(10)
|