Why The Prevoius Value Still Exists After Reinitialaize Variable - Php
Solution 1:
$carname;
does not in fact do anything. It's neither using the variable for any operation, nor is it assigning anything to it. In PHP variables are "initialised" by assigning something to them. If anything, $carname;
is the same as echo $carname;
without the echo
, it's just a NOOP. In fact, the first line doesn't do anything either, the first var_dump
triggers an Undefined variable carname
notice.
Solution 2:
Writing:
$carName;
doesn't initialize the variable. It reads the variable but doesn't do anything with the value that it read.
You need to assign null
to it:
$carName = null;
Solution 3:
Latest implementation of PHP totally ignores $carName;
line.
$data;
echo$data;
Opcode.
line # * op fetch ext return operands
-----------------------------------------------------------------------40> ECHO !01>RETURN1
http://3v4l.org/c3snU/vld#tabs
Other implementations treat this line as read operation and raise Undefined variable
notice.
Solution 4:
If you need $carName to be null you should set it as null:
$carName = null;
$carName; alone doesn't anything.
Post a Comment for "Why The Prevoius Value Still Exists After Reinitialaize Variable - Php"