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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:44:52+00:00 2026-05-27T05:44:52+00:00

Last time I’m exploring PHP pretty much and I was curious if it’s possible

  • 0

Last time I’m exploring PHP pretty much and I was curious if it’s possible to define variable without initializing it like in C++.

Well interpreter doesn’t output an fatal eror (only a notice that variable test is undefined) if I’ll run this code:

<?php 

$test = (int) $test;

?>

And if I try to check it with var_dump() function i get:

int(0)

I assumed interpreter automatically cast undefined to integer. Well, ok it’s pretty clever.
But when I removed code repsonsible for type casting and checked it with var_dump() function I get:

NULL

Well, ok. So when I assign undefined variable as undefined variable I get variable with NULL. I can understand interpreter do it for me on the run. But when I try something like this:

<?php

var_dump($test);
var_dump($test);

?>

I get two notices that test is not defined, but var_dump() returns NULL, not undefined. And now I don’t get it. If I’ll turn off notices var_dump() function will have same result with undefined variables and variables assigned to NULL. And here comes a question from topic. Why interpreter (or rather a var_dump() function) treats undefined and NULL as same ?

  • 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-05-27T05:44:53+00:00Added an answer on May 27, 2026 at 5:44 am

    The special NULL value represents a variable with no value. NULL is the only possible value of type NULL.

    A variable is considered to be null if:
    it has been assigned the constant NULL.
    it has not been set to any value yet.
    it has been unset().

    (int)$test = casting, force a value to data type (integer)

    warning notices = cause by $test is never defined, and you trying to use it

    var_dump($test) = I dun have a value for $test, so, I return you a null (by PHP)

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

Sidebar

Related Questions

How can I display the last time the current document was updated in PHP?
Sessions in PHP seemed to have changed since the last time I used them,
Last time I did PHP I worked with CodeIgniter. To implement AJAX I used
I'd like to determine the last time a specific line was changed in an
Last time I worked with PDF generation/.DOC generation in PHP it was awful, and
I'm learning PHP5 (last time I checked PHP was in PHP4 days) and I'm
I'm reposting this question as I didn't get much of a response last time,
I have always used relative paths in PHP. Last time I have realized that
Is it possible to geht the date, when a xml-file last time was changed.
Last time I used two parameter to query & show report. It worked well.

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.