Masca Posted July 13, 2007 Share Posted July 13, 2007 Hi! Please help! I am sure there must be a simple way of doing what I want to do, but I can't find it! I would like to hold a url in a variable. The url contains another variable - e.g.: $url = '/a_page_name/' . $ref . '/'; My problem is that $ref is declared (via a MySQL query) after $url is declared. Is there a way of 'refreshing' $url once $ref has been declared, so that I only need to declare $url once in my header include file which is included at the beginning of all my pages? I know that I could place it in a separate file which could be included after the MySQL query, but I would rather avoid that if possible. I hope the above makes sense! TIA. Quote Link to comment https://forums.phpfreaks.com/topic/59823-refreshing-a-variable-in-a-variable/ Share on other sites More sharing options...
per1os Posted July 13, 2007 Share Posted July 13, 2007 The only thing that may work is $url a reference. $url &= '/a_page_name/' . $ref . '/'; At least as far as my knowledge goes, but I have no clue if that would work or not given the static portion. Quote Link to comment https://forums.phpfreaks.com/topic/59823-refreshing-a-variable-in-a-variable/#findComment-297461 Share on other sites More sharing options...
Masca Posted July 13, 2007 Author Share Posted July 13, 2007 Thanks frost110, but sadly that doesn't seem to work. If I echo $url after declaring $ref (e.g.: $ref = 1234;), the result is just '0'. Quote Link to comment https://forums.phpfreaks.com/topic/59823-refreshing-a-variable-in-a-variable/#findComment-297467 Share on other sites More sharing options...
sasa Posted July 13, 2007 Share Posted July 13, 2007 trx <?php $a = '$url = "/a_page_name/" . $ref . "/";'; $ref = 123; eval($a); echo $url, "<br />\n"; $ref = 'abcd'; eval($a); echo $url, "<br />\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/59823-refreshing-a-variable-in-a-variable/#findComment-297522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.