Forum Moderators: coopster

Message Too Old, No Replies

string replace using header

         

dave1236

6:28 pm on Oct 13, 2006 (gmt 0)

10+ Year Member



I define a registered user by using the following:

.str_replace("tracking",$_SESSION['tracking'],$link).

I thought I could simply take that string above and replace

header("Location: $externalurl");

with

header("Location: $.str_replace("tracking",$_SESSION['tracking'],$link");

but that does not actually work! I then tried defining a new variable:

$URL = .str_replace("tracking",$_SESSION['tracking'],$link);
header("Location: $URL");

but that didn't work either...

Thoughts?

mrnoisy

2:25 am on Oct 14, 2006 (gmt 0)

10+ Year Member



I can see a couple of syntax errors: remove the '$' and '.' from before the str_replace function.

eelixduppy

2:55 am on Oct 14, 2006 (gmt 0)



Actually that wouldn't result correctly, either. Using both your techniques you can do this:

$URL = str_replace("tracking",$_SESSION['tracking'],$link); //I just removed the period
header("Location: $URL");

Or you can do this:


header("Location: ".str_replace("tracking",$_SESSION['tracking'],$link);

For more information about what is accomplished here, refer to the String Operators Documentation [us2.php.net]

:)