%26lt;?php $tempvar = $_GET['c']; ?%26gt;
%26lt;a href="index.php?c=1"%26gt;Home%26lt;/a%26gt;
If ($tempvar == 1) include('home.php')
The a href above sets c=1 . How could i pass text c="red" in a string
%26lt;?php $tempvar = $_GET['c']; ?%26gt;
%26lt;a href="index.php?c="red""%26gt;Home%26lt;/a%26gt;
If ($tempvar == "red") include('home.php')
What should i use instead of the "" around red,
is it %26amp;quo something
"index.php?c=%26amp;quored%26amp;quo ???
thanks
Proper syntax with PHP for passing text in string question?
In the URL you dont use the quotes. PHP will understand it to be a string.
Instead of
%26lt;a href="index.php?c="red""%26gt;Home%26lt;/%26gt;
Try
%26lt;a href="index.php?c=red"%26gt;Home%26lt;/a%26gt;
If for some reason you need a quote then you can use the " but I am sure you dont need it.
%26lt;a href="index.php?c=red"%26gt;Home%26lt;/a%26gt;
In PHP the var $c will hold a string of "red" (no quotes of course).
Reply:You should use ?a=1 for one value and ?a=1%26amp;b=2%26amp;c=3 for multiple values.
No quotes needed. :)
Reply:All values passed as a parameter through a URL (like your link) are assumed to be strings, therefore it is not necessary to put quotes around your value.So if you wanted to make sure a value was an int, you would have to explicitly cast it as such (such as in your first example).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment