Elementary PHP problem
-
I’m having what is likely an elementary PHP problem …
Order of what’s happening:
in functions.php …
global $var, $varcolor; function get_var() { global $var; $var = 'pink'; /* This is just an example, I'm actually looking for a URL in a custom field. Which is why I have this running at get_header, so I can global $post and find the key and value. I also need to know if I'm looking at the home page or a post page with conditional tags. */ } add_action('get_header','get_var'); $varcolor = $var;
functions.php runs, does it’s business.
We get the header loading, $varcolor = ‘pink’ and all is right with the world. The header finishes loading, style.css loads and imports style.php like so …
@import "style.php";
Style.php does it’s thing but! it won’t find $varcolor. When I try and use $varcolor like
body {background:$varcolor;}
nothing happens. Everything thing else in style.php (including other dynamic stuff I’m doing there) works. It should set the background as pink, right?
It’s probably some elementary PHP thing that I’m missing. Any clue?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Elementary PHP problem’ is closed to new replies.