Does the `delete` keyword in PHP do what it does in C++ or similar?
Just for curiosity, I typed delete
on an editor with PHP syntax highlighting and it put it with a known keyword color.
unset()
which when used on a reference I assume triggers garbage collection, resource freeing or whatever PHP does under the hood, but what does delete
do?
When trying delete $ref
o开发者_如何学Pythonn a reference variable, I get this error: Parse error: syntax error, unexpected T_VARIABLE in /... on line ...
Your editor is confused. There is no delete
keyword in PHP.
If you look in the manual, amusingly all it says is that it's a "dummy manual entry" for people who are really looking for unlink()
or unset
. For your case of getting rid of a reference variable, unset
does the same thing except it doesn't destroy the value, only that particular reference.
Additionally, although it says void delete ( void )
in the function prototype, no such function actually exists.
According to meaning of 'delete' in C, you talk about 'unset()' function in PHP...
unset($var);
// or
unset($var1, $var2,...);
精彩评论