views:

63

answers:

5

I'm trying to change a hardcoded variable value to dynamic, but can't seem to get the concatenation correct...

The hardcoded value is...

$token = "../wp-content/themes/mytheme/styles/test/sidebar";

And I'm trying to replace that with...

$token = ".get_bloginfo('template_directory')."styles/test/sidebar";

But its not working the same as when I hardcode the value.

What am I missing?

Here's the rest of the code (the imagegif function never fires with the dynamically generated variable...

$color = imagecolorallocate($img, $info["red"], $info["green"], $info["blue"]);
    for ($i = $startPixel-1; $i < $endPixel; $i++)
    {
        imagesetpixel($img, $i, 0, $color);
    }

    imagegif($img, $token.'.gif');
}
+1  A: 
$token = get_bloginfo('template_directory') . "styles/test/sidebar";

The . is the concatenation operator, so you wouldn't want the get_bloginfo() function inside of quotes. This assumes the function returns a string that ends in a /

Fosco
Thanks Fosco, I missed that. Also had to put a "/" in front of "styles".
Scott B
A: 
$token = get_bloginfo('template_directory')."styles/test/sidebar";

Is that what you mean? You had the function as a string instead of a function.

Gazler
A: 

From your code:

$token = ".get_bloginfo('template_directory')."styles/test/sidebar";

This line has a a stray quote and period at the beginning. You probably wanted to do:

$token = get_bloginfo('template_directory') . "styles/test/sidebar";

Function calls cannot be within strings, and the concatenation operator (.) must be outside of the string.

Daniel Vandersluis
A: 

Only strings should be wrapped within quotes.

$token = get_bloginfo('template_directory') . "styles/test/sidebar";
RobertPitt
A: 

Your concatination is a bit off.

Try: $token = get_bloginfo('template_directory') . 'styles/test/sidebar';

vjo
"Your concatination is a bit off."... is that not the question ?
RobertPitt
Maybe I meant his style of concatenating being a bit weird. But yeah, that was the question I guess ;-)
vjo