Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $a=1;
- function $test(){
- echo $a;
- }
- //outputs 1
- $test = array(
- 0=>'zero',
- 1=>'one',
- 2=>'two',
- 3=>'three',
- );
- function doesntWork($something){
- echo "My favorite number is " . $test[$something];
- }
- //outputs My favorite number is 0
- <?php
- $a=1;
- function test($foo) {
- echo 'number ' . $foo;
- };
- test($a);
- // -> "number 1".
- ?>
- <?php
- $test = array(
- 0=>'zero',
- 1=>'one',
- 2=>'two',
- 3=>'three',
- );
- function doesntWork($test, $something){
- echo "My favorite number is " . $test[$something];
- }
- doesntWork($test, mt_rand(0,3));
- ?>
- function test() {
- global $a;
- echo $a;
- }
- function doesWork($something) {
- global $test;
- echo "My favorite number is " . $test[$something];
- }
Add Comment
Please, Sign In to add comment