Fandom

Programmer's Wiki

Undefined

408pages on
this wiki
Add New Page
Talk0 Share

A variable is said to be undefined (or some variant thereof) in various situations according to the language context.

In the lower languages (e.g. C, C++), an uninitialized variable holds an arbitrary value which must be replaced before use to avoid undefined behavior (typically a segmentation fault).

JavaScript provides the undefined literal, which implies as a variable's value that the program simply has not used the variable yet, whereas null means the program has explicitly deemed the value unknown. However, undefined can be assigned to a variable or returned from a function just as easily as null.

In PHP, undefined is replaced with the isset and unset language constructs. I.e., "unset" is only the state of a variable rather than its value and will not be transferred by assignment except by reference. (An assignment by value would actually set the left variable to null.) Handling an unset variable as if it were set will cause an E_NOTICE error[1] (similar to the segmentation fault above).

ReferencesEdit

  1. http://www.php.net/manual/en/types.comparisons.php

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.