LC8Joe Posted April 5, 2013 Share Posted April 5, 2013 I'm trying parse this line: echo '<a href="'.$_SERVER['PHP_SELF'].'?function='$i'">Click here to call a function</a>'; and keep getting an error, how can I place the value of i$ ? Can you please help me? Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 5, 2013 Share Posted April 5, 2013 Variables do not get parsed inside single quoted strings. Either use double quotes and escape your existing double quotes, or use concatenation. Quote Link to comment Share on other sites More sharing options...
LC8Joe Posted April 5, 2013 Author Share Posted April 5, 2013 Hi Jessica, thank you very much for your answer but it seams that I just don't get it I'm trying to get the value of $i when I click the link but even when I don't get a parse error, it will call function= with no value returned $i = 55;echo '<a href=\"'.$_SERVER['PHP_SELF'].'?function="$i"'.">Click here to call the function</a>";if(isset($_GET['function'])){ echo $_GET['function'];} Quote Link to comment Share on other sites More sharing options...
exeTrix Posted April 5, 2013 Share Posted April 5, 2013 (edited) Try this: echo '<a href="' . $_SERVER['PHP_SELF'] . '?function=' . $i . '">Click here to call the function</a>'; What Jessica meant was you could do this: echo "<a href=\"{$_SERVER['PHP_SELF']}?function={$i}\">Click here to call the function</a>"; Double quotes will allow you to place variables in he string. However, the first method is quicker to parse Edited April 5, 2013 by exeTrix Quote Link to comment Share on other sites More sharing options...
LC8Joe Posted April 7, 2013 Author Share Posted April 7, 2013 Thx exeTrix! U saved my day Quote Link to comment 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.