answersLogoWhite

0

Problem with using global variables in php is that they lose the the assigned value in a different php file. They only keep the global variable value in the php file in which they are declared.

Instead of globals try and use $_SESSION or $_COOKIE to keep value intact across different php files in a project

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
EzraEzra
Faith is not about having all the answers, but learning to ask the right questions.
Chat with Ezra
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin

Add your answer:

Earn +20 pts
Q: When should globals be used in PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp