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 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 68k
  • Answers 68k
  • 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
  • added an answer Just use a transaction, and call Transaction.Rollback() on error. It's… May 11, 2026 at 12:09 pm
  • added an answer If you are looking at a navigation property (i.e. some… May 11, 2026 at 12:09 pm
  • added an answer The system is saying that there has been an attempt… May 11, 2026 at 12:09 pm

Related Questions

I used jQuery to set hover callbacks for elements on my page. I'm now
I used the ASP.NET Configuration wizard to set up a web user. I then
I used the command line arp -s IP MAC command to set a static
I have a TSQL script that is used to set up a database as
I have a FreeBSD box with Bash set up. I'm used to Debian Linux
I'm working on a set of classes that will be used to serialize to
I used to work in a place where a common practice was to use
I used to be able to do the following in Preview 3 <%=Html.BuildUrlFromExpression<AController>(c =>
I used to work with eclipse for nearly all the languages I need. I'm
I used to use the standard mysql_connect(), mysql_query(), etc statements for doing MySQL stuff

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.