Forum Moderators: coopster
I've got file that I use as a template which has various variables, with block of html in it.
example: $footer, $header, etc.
The actual webpage calls this include file and then references the blocks of code appropriate for it.
I have one block of code for some ads that only appear on certain pages.
So in my include file, I added a function to check if the variable $adverts is set, and if so, display the $adverts html.
I can't seem to get it working though.
Here's my function:
function check_ads() {
if (isset($adverts)) {
echo $adverts;
}
} and then in my page.php file I've got
<? $adverts = 'this is my ad'; ?> Any ideas where I'm going wrong? I'm sure it must be something simple.
function check_ads() {
if (isset($adverts)) {
echo $adverts;
}
}
function check_ads($adverts) {
if (isset($adverts)) {
echo $adverts;
}
}
Have a look at the second example on [uk.php.net...]
<edit>
The alternative would be to use global
function check_ads() {
global $adverts;
if (isset($adverts)) {
echo $adverts;
}
}
[edited by: PHP_Chimp at 3:29 pm (utc) on Sep. 5, 2008]