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 9134259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:37:43+00:00 2026-06-17T08:37:43+00:00

Is undefined a data-type in php? Also, how does one check for it (on

  • 0

Is undefined a data-type in php?
Also, how does one check for it (on a variable, is or is not undefined)?

  • 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-17T08:37:44+00:00Added an answer on June 17, 2026 at 8:37 am

    There is no “undefined” data type in PHP. You can check for a variable being set with isset, but this cannot distinguish between a variable not being set at all and it having a null value:

    var_dump(isset($noSuchVariable)); // false
    
    $nullVariable = null;
    var_dump(isset($nullVariable)); // also false
    

    However, there is a trick you can use with compact that allows you to determine if a variable has been defined, even if its value is null:

    var_dump(!!compact('noSuchVariable')); // false
    var_dump(!!compact('nullVariable')); // true
    

    Live example.

    Both isset and the compact trick also work for multiple variables at once (use a comma-separated list).

    You can easily distinguish between a null value and total absence when dealing with array keys:

    $array = array('nullKey' => null);
    
    var_dump(isset($array['nullKey'])); // false
    var_dump(array_key_exists($array, 'nullKey')); // true
    

    Live example.

    When dealing with object properties there is also property_exists, which is the equivalent of array_key_exists for objects.

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

Sidebar

Related Questions

I'm looping my object data but am getting this undefined value. Not sure why
I have this error NOTICE: UNDEFINED VARIABLE: LOGO IN C:\WAMP\WWW\SITE\TOOLS\SMARTY\SYSPLUGINS\SMARTY_INTERNAL_DATA.PHP ON LINE 291 CALL
Notice: Undefined variable: username in C:\xampp\htdocs\test_class.php on line 20 Notice: Undefined variable: password in
I have an AJAX script that post data in one of my PHP file:
In this code I have a callback undefined error: function getPacakage(callback){ var sendurl={address:'http://ip/bms/data.php?result=10&order=28'} var
I have this form: <form action=image_upload.php method=post enctype=multipart/form-data> Image 1: <input type=file name=event_image />
My HTML code <form method=post enctype=multipart/form-data action=upload.php> <input type=file name='image' > <input type=SUBMIT value=Submit>
I have this script: $.ajax({ url: 'submit_to_db.php', type: 'POST', data: 'name=' + name +
Hello guys that is not normal :) !! foo.php <?php if (isset($_POST['data'])) $stringData =
function addFav(id){ $.ajax({ url: misc/favAdd.php, type: POST, data: { mode: 'ajax', user: id}, dataType:

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.