Link to home
Start Free TrialLog in
Avatar of blink10
blink10

asked on

Php header...

Any ideas why it will not accept my variable as variable. It thinks it is a string value.


// The link is variable depending on the page.
$txnlink = http://www.google.com;

header('Refresh: 4; URL =$txnlink');

Open in new window

Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

// The link is variable depending on the page.
$txnlink = "http://www.google.com";

header('Refresh: 4; URL =$txnlink');
ASKER CERTIFIED SOLUTION
Avatar of LAMASE
LAMASE

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LAMASE
LAMASE

Ah, and you use quotes in the other string, too

$txnlink = "http://www.google.com";

Open in new window

Here is the man page about string definitions.  You really want to read this and understand the syntax completely.
http://www.php.net/manual/en/language.types.string.php

Here is the man page about the header() function. Whenever you are not 100% sure what a PHP function does, you can find the function documentation online.  Take note of the very common error about the use of header() after browser output has already occurred.  Even invisible whitespace can cause problems for your script.
http://us2.php.net/manual/en/function.header.php

It looks like you mean to cause the client browser to refresh and redirect to Google after 4 seconds.  You can do this, of course, but from a UX standpoint, I think I would ask myself if this is really a good thing for the client.  What will they see on the screen for 4 seconds?  Is 4 seconds a sensible length of time to display this information?  What can a client do with the information that will disappear after 4 seconds?  You might want to ask yourself, is it really necessary to display this at all?