Home  >  Article  >  Backend Development  >  What is the way to destroy variables in php

What is the way to destroy variables in php

王林
王林Original
2020-08-12 15:23:192983browse

How to destroy variables in php: We can use the unset() function to destroy a given variable. Specific usage methods are: [unset($foo)], which means a single variable is to be destroyed; [unset($foo1, $foo2, $foo3)], which means multiple variables are to be destroyed.

What is the way to destroy variables in php

#You can use the unset() function to destroy a given variable.

(Recommended tutorial: php graphic tutorial)

Note: This function has no return value.

Syntax:

void unset ( mixed $var [, mixed $... ] )

Parameters:

  • $var: Variable to be destroyed

(Learning video recommendation: php video tutorial)

Example:

<?php
// 销毁单个变量
unset ($foo); 
// 销毁单个数组元素
unset ($bar[&#39;quux&#39;]); 
// 销毁一个以上的变量
unset($foo1, $foo2, $foo3);
?>

The above is the detailed content of What is the way to destroy variables in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn