Activity 4 - Feb 9, 2026

Submitted by Brendan Morrissey


Variable Scope

The value of global variable x is 10

Warning: Undefined variable $x in /home/bmorriss/public_html/in-class/Activity_Four.php on line 18
Access the global variable x inside a function
This will not work because $x is not defined in the local scope of the function
Now we can access the global variable x inside the function: 10
The value of local variable y is 20

Warning: Undefined variable $y in /home/bmorriss/public_html/in-class/Activity_Four.php on line 29
Access the local variable y outside of TestScope():
This will generate an error.

Using Loop to build tables

Table 11

You can access the global variable x inside the loop: 10
The value for variable x is 10
01234567
01234567
01234567
01234567
01234567
01234567
01234567
01234567
Table 2
012345678
012345678
012345678
012345678
012345678
012345678
012345678
012345678
Table 3
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
Table 4
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
012345678910111213141516171819
Table 5
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >
0< >1< >2< >3< >4< >5< >6< >7< >8< >9< >10< >11< >12< >13< >14< >15< >16< >17< >18< >19< >