1

I am following this PHP tutorial for getting hold of some basic PHP stuff -> http://html.net/tutorials/php/lesson10.php.

Here it says that if we enter an URL like this:-> http://html.net/page.php?name=Joe, it will pass value "Joe" to the variable "name" of the page.php script.

This makes me wonder if we can pass multiple names (except that of Joe) to page.php script via something like http://html.net/page.php?name!=Joe ? Is this legal syntax or is there another way of achieving this.

2
  • no ... in short, though this is not a PHP thing but a part of the URL specification en.wikipedia.org/wiki/Query_string Commented Jun 29, 2017 at 5:16
  • that said you can pass in something like this http://html.net/page.php?not_name=Joe and then you just code it knowing that it's not_name of Joe ... lol Commented Jun 29, 2017 at 5:18

2 Answers 2

2

No You can't pass like this. But if you want to comapre the value. You can pass extra query string param which indecates whether to match value or doesn't match. For example:

http://html.net/page.php?name=Joe&match=0

Which indecates you want result with name = "Joe" (if match = 0)

and

http://html.net/page.php?name=Joe&match=1

Which indecates you want result with name != "Joe" (if match = 1)

Sign up to request clarification or add additional context in comments.

Comments

0

No. To achieve that you could send the exclusions on another variable name called "exclusions" and then have some sort of filtering on the serverside.

Like this: http://html.net/page.php?name=Maria,Peter&exclusions=Joe

1 Comment

Id use the array syntax for multiple names http://html.net/page.php?name[]=Maria&name[]=Peter&exclusions=Joe That's just me though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.