Bird
0
0

Why is using global variables considered dangerous in PHP?

easy📝 Conceptual Q11 of 15
PHP - Request Lifecycle
Why is using global variables considered dangerous in PHP?
ABecause they can be changed anywhere, causing unexpected bugs
BBecause they make the code run faster
CBecause they prevent the use of functions
DBecause they automatically encrypt data
Step-by-Step Solution
Solution:
  1. Step 1: Understand what global variables do

    Global variables can be accessed and modified from any part of the program.
  2. Step 2: Identify the risk of global variables

    Since they can be changed anywhere, it is easy to accidentally overwrite or misuse them, leading to bugs that are hard to find.
  3. Final Answer:

    Because they can be changed anywhere, causing unexpected bugs -> Option A
  4. Quick Check:

    Global variables cause unexpected bugs [OK]
Quick Trick: Global variables can be changed anywhere, causing bugs [OK]
Common Mistakes:
  • Thinking global variables improve performance
  • Believing global variables prevent function use
  • Assuming global variables encrypt data automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes