ArizonaJohn Posted June 5, 2009 Share Posted June 5, 2009 Hi, The code below is on a page where a variable called $find has a value. If I wanted to push that $find value through to search2.php, what is the best way to do that? Thanks. $anymatches=mysql_num_rows($result); if ($anymatches == 0) { header("Location:search2.php"); exit; } Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/ Share on other sites More sharing options...
Wolphie Posted June 5, 2009 Share Posted June 5, 2009 Probably GET would be the best method. header('Location: search.php?find=' . $find); Then you could recover it in search.php using: $_GET['find'] Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-849811 Share on other sites More sharing options...
dreamwest Posted June 5, 2009 Share Posted June 5, 2009 You wont nee to concat if its in double quotes - less work header("Location: search.php?find=$find"); Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-849813 Share on other sites More sharing options...
GingerRobot Posted June 5, 2009 Share Posted June 5, 2009 You wont nee to concat if its in double quotes - less work Less work for you maybe. But more work for the PHP engine. Admittedly it's not going to make a huge difference in the grand scheme of things, but yeah. Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-849821 Share on other sites More sharing options...
dreamwest Posted June 5, 2009 Share Posted June 5, 2009 You wont nee to concat if its in double quotes - less work Less work for you maybe. But more work for the PHP engine. Admittedly it's not going to make a huge difference in the grand scheme of things, but yeah. Serious? Ive been using {$variables} like crazy, didnt think it made any difference Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-849930 Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 If you have 10k of them (not in an echo statement), it adds about 1ms to the page generation time. If you are echoing the string they are in, it is actually faster using {$variables} inside the quoted string. Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-849932 Share on other sites More sharing options...
ArizonaJohn Posted June 5, 2009 Author Share Posted June 5, 2009 Thanks Wolphie and Dreamwest, it works. -John Link to comment https://forums.phpfreaks.com/topic/161028-solved-pushing-a-variable-through-while-using-header/#findComment-850261 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.