Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //$thevar starts undefined
- $thevar["that"]=5;
- var_dump($thevar);
- // outputs
- // array(1) {
- // ["that"]=>
- // int(5)
- // }
- $thevar=null;
- var_dump($thevar);
- $thevar["that"]=5;
- var_dump($thevar);
- // outputs
- // NULL
- // array(1) {
- // ["that"]=>
- // int(5)
- // }
- $thevar=false;
- var_dump($thevar);
- $thevar["that"]=5;
- var_dump($thevar);
- // outputs
- // bool(false)
- // array(1) {
- // ["that"]=>
- // int(5)
- // }
- // all code above outputs with no warnings
- $thevar=true;
- var_dump($thevar);
- $thevar["that"]=5;
- var_dump($thevar);
- // outputs
- // bool(true)
- // stderr - PHP Warning: Cannot use a scalar value as an array
- // bool(true)
Advertisement
Add Comment
Please, Sign In to add comment