hi I was looking at a php code from social engine and they have something like this:
header("Location:user_event.php?event_id={$event_id}&justadded=1")
why id it not
header("Location:user_event.php?event_id=$event_id&justadded=1")
or
header("Location:user_event.php?event_id=".$event_id."&justadded=1")
because the value of $event_id is correct but when the page redirects I go to:
user_event.php?event_id=&justadded=1
now I'm sure I did something to mess the value of {$event_id} but I don't even know what it means. does it have to do with smarty?
Using {$variable} inside of double quoted strings, is for two reasons: a) to prevent mistakes like:
b) allowing to insert variables of arrays and objects into the string without interrupting it
But all of this shouldn't have any effect with Smarty, because Smarty only parses { } entities inside of the template files and
header("Location: ....");
definitly doesn't belong there, unless you have a{php}header("Location:...");{/php}
If you have the later one, than you have to access the $event_id differently, because it's not accessible from inside the Smarty class, unless you assign it first with
than either
or
But having this kind of code inside the template is quite wrong. Usually such stuff should be done in the actuall php file before the template is ever called.