Scope for PHP Variables Assigned in functions.php or a plugin

Question

I’m a web developer who works on WordPress sites and want to ensure I keep PHP variables out of the global scope. I have questions about this:

  1. If I created a $new_title = "test seo title"; variable in an active theme’s functions.php file, is that $new_title variable accessible (not undefined) in the active theme’s PHP files? Is that variable also accessible in the active plugin files?

  2. Also, if I created a $new_title2 = "test seo title2"; variable inside an active plugin, is that $new_title2 variable accessible (not undefined) in active theme’s functions.php file and other theme PHP files?

0
risingPhoenix1979 4 months 2022-04-08T11:46:52-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse