Php - Scope of Variables
We just introduced functions, now along with functions comes Scope of variables. In common day example i will try to give a general explanation of scope. If you have 4 tvs in different rooms, with 4 cables box, then each tv can show a different channel. Thus each “variable/tv” has it own “scope/show”. If you have 4 tvs, and 3 cables boxes and 2 tvs sharing a cable box. Then you will only have 3 different shows. In this instance a “variable/tv will have the same value on “2 area/rooms” and the other 2 (tv/variables) will have their own “scope/show”. So that if you change the value in one room where the tv is shared the other room is affected. That is how scope works, depending on the section you are in a variable can have one value and in another section it could have a different value, all depends on where is declared… (more…)