Hey guys, welcome back to my channel Ndev tuts.In this tutorial, we will learn about Special Datatypes in PHP and how to use them
effectively in the program. There are two special Datatypes in PHP .first is null
second is resource. let's talk about PHP null. The special null value is used to
represent empty variables in PHP. Null is a special datatype which can have only
one value "null". a variable of datatype null is a variable that has no value
assigned to it. if a variable is created without a value, it is automatically
assigned a value of null. a variable of type null is a variable without any
data. to give a variable the null very simply assign it like this
the special
constant null is capitalized by convention but actually it is
case insensitive you could just as well as have typed.
PHP developers mistakenly consider both
and are same but
this is not true, both variables are different the $var1 has
null while $var2 indicate no value
assigned to it. a variable that has been assigned null has the following property
first it evaluates to false in a boolean context. second its returns false
when tested with Isset() function. let's see the example of PHP null value. here
to create one PHP file null.php
let's writing a code.
variable can also empty by setting the value to null
save the code. let's run the program
this is the output screen. The special resource type is not an actual data type
it is the storing of a reference to functions and resources external to PHP
a common example of using the resource data type is a database call. we will not talk
about the resource type here since it is an advanced topic.
Không có nhận xét nào:
Đăng nhận xét