Passing PHP variables to an included file?

前端 未结 4 1632
傲寒
傲寒 2020-12-21 00:07

This should work, so I\'m really perplexed about why it\'s not working.

I\'m checking to see if a user is logged in using a $session class method at the top of each

4条回答
  •  难免孤独
    2020-12-21 00:38

    Just an opinion... instead of including code to execute in the global space and depending on another global variable being defined, include your file wherever and have the code inside header.php be organized into appropriate functions. Then where you want the output from header.php, call the appropriate function with the $logged as an argument. This will help make your code more cohesive and easier to test (as in unit tests).

提交回复
热议问题