Hướng dẫn what is unset function in php? - hàm unset trong php là gì?

❮ Tham chiếu xử lý biến PHP

Thí dụ

Biến số không đặt:

$a = "Hello world!";
echo "The value of variable 'a' before unset: " . $a . "
";
unset($a);
echo "The value of variable 'a' after unset: " . $a;
?>

Hãy tự mình thử »


Định nghĩa và cách sử dụng

Hàm unset () giải quyết một biến.


Cú pháp

Giá trị tham số

Tham sốSự mô tả
Biến đổiYêu cầu. Chỉ định biến để hủy bỏ
...Không bắt buộc. Một biến khác để hủy bỏ

Chi tiết kỹ thuật

Giá trị trở lại:Không có
Loại trở lại:Không có
Loại trở lại:Phiên bản PHP:

❮ Tham chiếu xử lý biến PHP


(Php 4, Php 5, Php 7, Php 8)

Unset - Und đặt một biến đã choUnset a given variable

Sự mô tả

Hành vi của unset () bên trong một hàm có thể thay đổi tùy thuộc vào loại biến bạn đang cố gắng phá hủy.unset() inside of a function can vary depending on what type of variable you are attempting to destroy.

Nếu một biến toàn cầu hóa không được đặt () bên trong một hàm, chỉ có biến cục bộ bị phá hủy. Biến trong môi trường gọi sẽ giữ lại giá trị giống như trước khi unset () được gọi.unset() inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset() was called.

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>

Ví dụ trên sẽ xuất ra:

Để giải quyết () một biến toàn cầu bên trong hàm, sau đó sử dụng mảng $ globals để làm như vậy:unset() a global variable inside of a function, then use the $GLOBALS array to do so:

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>

Nếu một biến được truyền bởi tham chiếu là unset () bên trong một hàm, chỉ có biến cục bộ bị phá hủy. Biến trong môi trường gọi sẽ giữ lại giá trị giống như trước khi unset () được gọi.unset() inside of a function, only the local variable is destroyed. The variable in the calling environment will retain the same value as before unset() was called.

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>

Ví dụ trên sẽ xuất ra:

Để giải quyết () một biến toàn cầu bên trong hàm, sau đó sử dụng mảng $ globals để làm như vậy:unset() inside of a function, unset() destroys the variable only in the context of the rest of a function. Following calls will restore the previous value of a variable.

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>

Ví dụ trên sẽ xuất ra:

Before unset: 1, after unset: 23
Before unset: 2, after unset: 23
Before unset: 3, after unset: 23

Để giải quyết () một biến toàn cầu bên trong hàm, sau đó sử dụng mảng $ globals để làm như vậy:

Nếu một biến được truyền bởi tham chiếu là unset () bên trong một hàm, chỉ có biến cục bộ bị phá hủy. Biến trong môi trường gọi sẽ giữ lại giá trị giống như trước khi unset () được gọi.

Nếu một biến tĩnh không được đặt () bên trong hàm, unSet () sẽ tiêu diệt biến chỉ trong bối cảnh phần còn lại của hàm. Các cuộc gọi sau đây sẽ khôi phục giá trị trước đó của một biến.

Thông số

var

Biến không được đặt.

vars

Các biến tiếp theo.

Trả về giá trịunset() example

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>

Không có giá trị được trả về.

Ví dụunset() function. (unset) casting serves only as a function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
1-type cast, for completeness. It does not alter the variable it's casting. The (unset) cast is deprecated as of PHP 7.2.0, removed as of 8.0.0.

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
2

Ví dụ trên sẽ xuất ra:

Để giải quyết () một biến toàn cầu bên trong hàm, sau đó sử dụng mảng $ globals để làm như vậy:

Nếu một biến được truyền bởi tham chiếu là unset () bên trong một hàm, chỉ có biến cục bộ bị phá hủy. Biến trong môi trường gọi sẽ giữ lại giá trị giống như trước khi unset () được gọi.: Because this is a language construct and not a function, it cannot be called using variable functions, or named arguments.

Nếu một biến tĩnh không được đặt () bên trong hàm, unSet () sẽ tiêu diệt biến chỉ trong bối cảnh phần còn lại của hàm. Các cuộc gọi sau đây sẽ khôi phục giá trị trước đó của một biến.:

Thông số

Nếu một biến tĩnh không được đặt () bên trong hàm, unSet () sẽ tiêu diệt biến chỉ trong bối cảnh phần còn lại của hàm. Các cuộc gọi sau đây sẽ khôi phục giá trị trước đó của một biến.:

Thông số

Nếu một biến tĩnh không được đặt () bên trong hàm, unSet () sẽ tiêu diệt biến chỉ trong bối cảnh phần còn lại của hàm. Các cuộc gọi sau đây sẽ khôi phục giá trị trước đó của một biến.:

Thông sốunset() on inaccessible object properties, the __unset() overloading method will be called, if declared.

var

  • Biến không được đặt.
  • vars
  • __unset()
  • Các biến tiếp theo.
  • Trả về giá trị

Không có giá trị được trả về.

Ví dụ

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
4

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
5

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
6

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
7

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Ví dụ #1 unset () ví dụ

Ví dụ #2 sử dụng (unset) đúc

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
9

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
0

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
1

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
2

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
3

(unset) Pha đúc thường bị nhầm lẫn với hàm Und (). (unset) đúc chỉ phục vụ như một diễn viên ____ 11 loại, cho sự hoàn chỉnh. Nó không làm thay đổi biến mà nó đúc. Diễn viên (UnST) được không dùng nữa là Php 7.2.0, được loại bỏ là 8.0.0.

Ví dụ #2 sử dụng (unset) đúc

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
4

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
5

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

(unset) Pha đúc thường bị nhầm lẫn với hàm Und (). (unset) đúc chỉ phục vụ như một diễn viên ____ 11 loại, cho sự hoàn chỉnh. Nó không làm thay đổi biến mà nó đúc. Diễn viên (UnST) được không dùng nữa là Php 7.2.0, được loại bỏ là 8.0.0.

Ghi chú

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
7

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
8

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
9

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
0

Lưu ý: Bởi vì đây là một cấu trúc ngôn ngữ và không phải là một hàm, nó không thể được gọi là sử dụng các hàm biến hoặc các đối số được đặt tên.

Ghi chú:

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
1

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
2

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Có thể giải phóng các thuộc tính đối tượng có thể nhìn thấy trong bối cảnh hiện tại.

Không thể tháo gỡ function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
3 bên trong một phương thức đối tượng.

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
4

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
5

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
6

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
7

function foo(&$bar
{
    unset(
$bar);
    
$bar "blah";
}
$bar 'something';
echo 
"$bar\n";foo($bar);
echo 
"$bar\n";
?>
8

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Khi sử dụng unset () trên các thuộc tính đối tượng không thể truy cập, phương thức quá tải __unset () sẽ được gọi, nếu được khai báo.

Xem thêm

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
0

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
1

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
2

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
3

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

ISSET () - Xác định xem một biến được khai báo và khác với NULL

Không thể tháo gỡ function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
3 bên trong một phương thức đối tượng.

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
5

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
6

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
7

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
8

Khi sử dụng unset () trên các thuộc tính đối tượng không thể truy cập, phương thức quá tải __unset () sẽ được gọi, nếu được khai báo.

Xem thêm

function foo()
{
    static 
$bar;
    
$bar++;
    echo 
"Before unset: $bar, ";
    unset(
$bar);
    
$bar 23;
    echo 
"after unset: $bar\n";
}
foo();
foo();
foo();
?>
9

var0

var1

var2

var3

var4

var5

var6

var7

var8

var9

vars0

vars1

vars2

vars3

vars4

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

ISSET () - Xác định xem một biến được khai báo và khác với NULL

Ghi chú:

vars6

vars7

vars8

vars9

Có thể giải phóng các thuộc tính đối tượng có thể nhìn thấy trong bối cảnh hiện tại.

Ghi chú

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
0

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
1

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
2

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
3

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
4

Lưu ý: Bởi vì đây là một cấu trúc ngôn ngữ và không phải là một hàm, nó không thể được gọi là sử dụng các hàm biến hoặc các đối số được đặt tên.

Ghi chú:

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
5

Có thể giải phóng các thuộc tính đối tượng có thể nhìn thấy trong bối cảnh hiện tại.

Xem thêm

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
6

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
7

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
2

// destroy a single variable
unset($foo);// destroy a single element of an array
unset($bar['quux']);// destroy more than one variable
unset($foo1$foo2$foo3);
?>
9

(unset)0

ISSET () - Xác định xem một biến được khai báo và khác với NULL

Ví dụ #2 sử dụng (unset) đúc

(unset)1

(unset)2

(unset)3

(unset)4

(unset)5

(unset)6

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

(unset) Pha đúc thường bị nhầm lẫn với hàm Und (). (unset) đúc chỉ phục vụ như một diễn viên ____ 11 loại, cho sự hoàn chỉnh. Nó không làm thay đổi biến mà nó đúc. Diễn viên (UnST) được không dùng nữa là Php 7.2.0, được loại bỏ là 8.0.0.

Không thể tháo gỡ function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
3 bên trong một phương thức đối tượng.

(unset)8

(unset)9

vars8

(unset)1

Khi sử dụng unset () trên các thuộc tính đối tượng không thể truy cập, phương thức quá tải __unset () sẽ được gọi, nếu được khai báo.

Không thể tháo gỡ function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
3 bên trong một phương thức đối tượng.

(unset)2

(unset)3

(unset)4

(unset)5

(unset)6

(unset)7

(unset)8

(unset)9

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
00

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
01

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
02

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
03

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
04

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
05

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
06

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
07

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Khi sử dụng unset () trên các thuộc tính đối tượng không thể truy cập, phương thức quá tải __unset () sẽ được gọi, nếu được khai báo.

Ví dụ #2 sử dụng (unset) đúc

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
09

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
10

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Có thể giải phóng các thuộc tính đối tượng có thể nhìn thấy trong bối cảnh hiện tại.

Ghi chú

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
12

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
13

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Lưu ý: Bởi vì đây là một cấu trúc ngôn ngữ và không phải là một hàm, nó không thể được gọi là sử dụng các hàm biến hoặc các đối số được đặt tên.

18 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
15

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
16

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
17

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Edouard Dot Berge tại Gmail Dot Com ¶

12 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
19

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
20

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
21

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
22

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

dibakar dot datta tại gmail dot com ¶

16 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
24

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
25

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
26

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
27

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Hayley Watson ¶

15 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
29

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
30

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Stacionari tại Gmail Dot Com ¶

14 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
32

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
33

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
34

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
35

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
36

Andreas ¶

12 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
37

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
38

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
39

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
40

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
41

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
42

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
43

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
44

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
45

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
46

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
47

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
48

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
49

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

dibakar dot datta tại gmail dot com ¶

16 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
51

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
52

function foo() 
{
    unset(
$GLOBALS['bar']);
}
$bar "something";
foo();
?>
2

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
54

Hayley Watson ¶

15 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
55

Stacionari tại Gmail Dot Com ¶

14 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
56

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
57

vars8

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
59

Andreas ¶

macnimble tại gmail dot com

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
60

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
61

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
62

13 năm trước

Chad 0x40 Herballure 0x2e com ¶

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
63

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
64

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
65

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
66

vars8

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
68

Tigercat tại Aol Dot Com ¶

10 năm trước

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
69

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
70

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
71

function destroy_foo() 
{
    global 
$foo;
    unset(
$foo);
}
$foo 'bar';
destroy_foo();
echo 
$foo;
?>
8

Đặt và mở khóa trong PHP là gì?

Hàm ISSET được sử dụng để kiểm tra xem một biến có được đặt hay không. Điều đó có nghĩa là nó xác định nếu một biến được gán một giá trị và không phải là null. Ngoài ra, chức năng PHP của ISSET kiểm tra xem biến đã cho không phải không được đặt bằng cách sử dụng hàm Untet.. That means it determines if a variable is assigned a value and is not null. Also, the isset PHP function checks if the given variable is not unset by using the unset function.

Sự khác biệt giữa unset () và thiếu liên kết () là gì?

Hàm hủy liên kết () được sử dụng khi bạn muốn xóa hoàn toàn các tệp. Hàm unset () được sử dụng khi bạn muốn làm cho tệp đó trống. The unset() Function is used when you want to make that file empty.

Chức năng nào được sử dụng để hủy bỏ một biến?

Hàm unset () là một hàm xử lý biến được xác định trước của PHP, được sử dụng để không đặt một biến được chỉ định.Nói cách khác, "hàm unset () phá hủy các biến".Hành vi của chức năng này khác nhau bên trong chức năng do người dùng xác định.unset() function is a predefined variable handling function of PHP, which is used to unset a specified variable. In other words, "the unset() function destroys the variables". The behavior of this function varies inside the user-defined function.

Điều gì tốt hơn trong việc giải phóng bộ nhớ bằng php unset () hoặc $ var null?

Bạn có thể nhận được bộ nhớ được giải phóng / thu nhỏ nhanh hơn, nhưng nó có thể đánh cắp các chu kỳ CPU từ mã thực sự cần chúng sớm hơn, dẫn đến thời gian thực hiện tổng thể dài hơn.Có vẻ như $ a = null nhanh hơn một chút so với đối tác unset () của nó: Cập nhật mục nhập bảng ký hiệu dường như nhanh hơn so với việc loại bỏ nó.$a = null is a bit faster than its unset() counterpart: updating a symbol table entry appears to be faster than removing it.