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

  • SEARCH
  • Home
  • 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 153697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:50:49+00:00 2026-05-11T09:50:49+00:00

I used to set things like this when I wanted blank values. $blankVar =

  • 0

I used to set things like this when I wanted blank values.

$blankVar = ''; 

Then after some months, I decided this looked better and had a clearer intent.

$blankVar = null; 

This worked without hiccup for a while, but recently with a PDO prepared statements I ran into a problem. Binding a value to null made the query fail, whilst binding it to ” did not. I needed to bind it to null, so that if a condition was met, it would insert blank data.

What are the differences between the 2? I still think equaling null (or at least a constant) looks better, so should I do this?

define('EMPTY', ''); 
  • 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. 2026-05-11T09:50:50+00:00Added an answer on May 11, 2026 at 9:50 am

    Null is just another datatype in PHP, which has only one value (null). Since PHP is a loosly typed language, it can be confusing how it handles different values.

    '', 0, '0', False, array(), Null are all considered False in PHP.

    Null, however, is a different kind of animal. The main incompatibility with using Null is that you cannot tell if it isset().

    $x = false; isset($x)  ->  true echo $x    ->  ''  $y = null; isset($y)  ->  false echo $y    ->  ''  //$z is not set isset($z)  ->  false echo $z    ->  E_NOTICE 

    So null is odd in the sense that it doesn’t follow normal variable rules in PHP (at least some). In most cases, it is fine.

    When it comes to database columns, PHP’s NULL has no place there. You see, SQL is a string based language. SQL’s NULL must be represented by NULL with no quotes.

    So if you want an EMPTY field, set it to ”

    INSERT INTO foo SET bar = '' 

    But if you want a NULL field, set it to NULL

    INSERT INTO foo SET bar = NULL 

    BIG DIFFERENCE.

    But if you try to insert the PHP NULL directly, it will add zero characters to the query, (which leaves you with a blank or syntax error, depending on if you quoted it).

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

Sidebar

Ask A Question

Stats

  • Questions 82k
  • Answers 82k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer GetNextWindow() is actually a macro for GetWindow(), rather than an… May 11, 2026 at 4:44 pm
  • Editorial Team
    Editorial Team added an answer is null works if the variable is actually NULL. If… May 11, 2026 at 4:44 pm
  • Editorial Team
    Editorial Team added an answer Not sure I understand your question correctly, but if you… May 11, 2026 at 4:44 pm

Related Questions

I need to host a WCF service in IIS that exposes a wsHttpBinding. That
I am using an api which interacts with a db. This api has methods
I am working on an application that will have online and offline components and
My main browsers (FF and Chrome) are both configured for a 12 pixel font.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.