When should globals be used in PHP?

1 answer

Answer

1083499

2026-04-18 03:30

+ Follow

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

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.