Global variables
-
I would like to store constants, like usernames and passwords, in a centralized constants.php file and then
include
that file in my snippet. However, within my snipped, global variables appear uninitialized. Example:Snippets Code:
include “/home/me/public_html/cgi-bin/constants.php”; // defines $x=42
add_shortcode(“my_shortcode”, “f”);
function f($atts) {
// …not using $atts for this example
return “x is ‘$x'”;
}Page’s Text Block content:
…just regular Text Block content showing that [my_shortcode].Page’s output:
…just regular Text Block content showing that x is ”.Page’s output that I was hoping for:
…just regular Text Block content showing that x is ’42’.Thank you so much.
- The topic ‘Global variables’ is closed to new replies.