Reputation: 85
I have seen some urls on facebook where at the end you see &theater
I assume this means it's somehow setting theater
to true
. I was wondering how to accomplish the same thing.
For instance:
example.com/page/?var
In this url, var
would be set true.
I know I can add =true
to the end of it to make it have the desired value, but I am asking this for convenience.
Upvotes: 2
Views: 97
Reputation: 146410
$var = isset($_GET['var']);
Now $var
is a boolean variable.
Upvotes: 0
Reputation: 4946
You can use
if(isset($_GET['var'])){
// true if var is set, even if it is empty
}
It is seen as a syntax error when one starts to declare $_GET['var'] when it is not set. PHP will throw an error at you, when error reporting set. It is good to see if it is set in the first place. If the var is oly to flag "true", then that is accomplished by just setting it. To accomplish setting a url with $_GET variables is just by adding them to a link the way you see them in the address bar.
Upvotes: 4