Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8474983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:46:23+00:00 2026-06-10T17:46:23+00:00

How can I send a true or false value in a querystring and then

  • 0

How can I send a true or false value in a querystring and then use it in php? I’m trying to do as follows, but it gives me true even when both are set to false. I’ll be getting these values from a htaccess file.

<?php
$var = $_GET['a'];
$bar = $_GET['b'];

if ($var && $bar)
{
echo "True";
}else
{
echo "False";
}

echo '<a href=?a=false&b=false>Check</a>';
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:46:25+00:00Added an answer on June 10, 2026 at 5:46 pm

    They’re both evaluating to True because you can’t send a proper boolean true or false through a querystring. Both the strings "true" and "false" evaluate to TRUE in PHP. Either do:

    if ($var == "true" && $bar == "true") {
    

    or send 0 and 1 instead of "true" and "false" from your data source (I’m not entirely clear on how your .htaccess fits in here – I’m assuming it’s massaging variables from a form field, but it’s ultimately irrelevant.)

    For more information, check out this incredibly massive table of PHP truth values. PHP’s type coercion – that is to say, its method of turning arbitrary variables into variables of other types – is difficult to predict and operates upon its own logic.

    That said, the querystring portion of the question isn’t intrinsically a PHP problem – there’s no canonical way to communicate booleans through GET or POST parameters. If you look, you’ll notice that every site handles it their own way – some use "true", others 1, and yet others use TRUE.

    There is one final alternative – JSON. Though it’s unlikely to help in your case, my preferred method for exchanging data with the server is by encoding all the data into a single string of JSON. This has a few benefits such as giving me that fine-grained control over the variable types encapsulated in my JSON object, but it has the drawback of not being something you can do with a vanilla HTML form. Great if you’re doing an AJAX-ey web app, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In ASP.net MVC 2, I can use routes.RouteExistingFiles = true; to send all requests
I save the value of a textarea id=save inside addEventListener . Then, I send
i'm trying to send an js object to a php function using jquery.ajax .
I have a thread running but from outside I can't bypass a value to
I'm trying to send json object to server. But I received an error and
I can send requests to friends using Multi Friend Request Selector inside my Page
I know that soap can send XML over http, is there any way to
How this UIButton rewind can send notification to UIButton play to perform playpauseaction method
In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
how i can send key from my C# program to external program ? ex:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.