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

Related Questions

I used the ASP.NET Configuration wizard to set up a web user. I then
I've seen that this kind of directives like [SWF...] and [Frame...] are used to
I have a TSQL script that is used to set up a database as
I used jQuery to set hover callbacks for elements on my page. I'm now
I used the command line arp -s IP MAC command to set a static
How can I set the font used by the FLVPlaybackCaptioning component for subtitles? Using
You might have a set of properties that is used on the developer machine,
I'm working on a set of classes that will be used to serialize to
How do I properly set the default character encoding used by the JVM (1.5.x)
There are a set of questions that seem to be commonly-used in interviews and

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.