Hướng dẫn what does the unset () function mean in php? - Hàm unset () có nghĩa là gì trong php?
❮ Tham chiếu xử lý biến PHP Show
Thí dụBiến số không đặt: $a = "Hello world!"; Hãy tự mình thử » Định nghĩa và cách sử dụngHàm unset () giải quyết một biến. Cú phápGiá trị tham số
Chi tiết kỹ thuật
❮ Tham chiếu xử lý biến PHP Ẩn danh ¶Lion_Cat tại Mail Ru ¶
Thorry tại Thorry Dot Netvoid unset ( mixed $var , mixed $vars ) Pauljamescampbell tại Gmail Dot Com ¶
Hayley Watson ¶Stacionari tại Gmail Dot Com ¶ Andreas ¶macnimble tại gmail dot com Chad 0x40 Herballure 0x2e com ¶Tigercat tại Aol Dot Com ¶ "; unset($a); echo "The value of 'a' after unset: " . $a; ?> 10 năm trướcMuhamad_zakaria tại Yahoo Dot Com ¶ The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset: Chad 0x40 Herballure 0x2e com ¶Tigercat tại Aol Dot Com ¶ Đầu raĐiều này sẽ tạo ra kết quả sau - global unset inside function =Welcome TutorialsPoint! Thí dụ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. Ví dụ sau chứng minh điều này - "; destroy_c($c); echo "$c Đầu raĐiều này sẽ không tạo ra kết quả - TutorialsPoint TutorialsPoint php_variable_handling_functions.htm (Php 4, Php 5, Php 7, Php 8) Unset - Und đặt một biến đã cho — Unset 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.
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:
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. "; unset($a); echo "The value of 'a' after unset: " . $a; ?>0 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. "; unset($a); echo "The value of 'a' after unset: " . $a; ?>1 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ố
"; unset($a); echo "The value of 'a' after unset: " . $a; ?>2 Biến không được đặt.
"; unset($a); echo "The value of 'a' after unset: " . $a; ?>3 Các biến tiếp theo.Trả về giá trịunset() example "; unset($a); echo "The value of 'a' after unset: " . $a; ?>4 Không có giá trị được trả về. Ví dụunset() function. "; unset($a); echo "The value of 'a' after unset: " . $a; ?>5 casting serves only as a "; unset($a); echo "The value of 'a' after unset: " . $a; ?>8-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. "; unset($a); echo "The value of 'a' after unset: " . $a; ?>9 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); echo "The value of 'a' after unset: " . $a; ?> 2
Không có giá trị được trả về. ¶ Ví dụ The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:1 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:2 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:3 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:4 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 Ví dụ #1 unset () ví dụ ¶ Ví dụ #2 sử dụng The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:6 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:7 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:8 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:9 0 Ví dụ #2 sử dụng 1 2 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 Ghi chú 4 5 6 7 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ú: 8 9 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset: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. ¶ Không thể tháo gỡ global unset inside function =Welcome TutorialsPoint!1 global unset inside function =Welcome TutorialsPoint!2 global unset inside function =Welcome TutorialsPoint!3 global unset inside function =Welcome TutorialsPoint!4 global unset inside function =Welcome TutorialsPoint!5 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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 global unset inside function =Welcome TutorialsPoint!7 global unset inside function =Welcome TutorialsPoint!8 global unset inside function =Welcome TutorialsPoint!9 "; destroy_c($c); echo "$c0 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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ỡ "; destroy_c($c); echo "$c2 "; destroy_c($c); echo "$c3 "; destroy_c($c); echo "$c4 "; destroy_c($c); echo "$c5 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 "; destroy_c($c); echo "$c6 "; destroy_c($c); echo "$c7 "; destroy_c($c); echo "$c8 "; destroy_c($c); echo "$c9 TutorialsPoint TutorialsPoint0 TutorialsPoint TutorialsPoint1 TutorialsPoint TutorialsPoint2 TutorialsPoint TutorialsPoint3 TutorialsPoint TutorialsPoint4 TutorialsPoint TutorialsPoint5 TutorialsPoint TutorialsPoint6 TutorialsPoint TutorialsPoint7 TutorialsPoint TutorialsPoint8 TutorialsPoint TutorialsPoint9 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 230 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 231 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 ISSET () - Xác định xem một biến được khai báo và khác với NULL ¶ Ghi chú: Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 233 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 234 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 235 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 236 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ú Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 237 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 238 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 239
function destroy_foo() 1Lư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ú:
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
Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 239
function destroy_foo() 7ISSET () - Xác định xem một biến được khai báo và khác với NULL ¶ trống () - Xác định xem một biến có trống không
The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 Array_Splice () - Xóa một phần của mảng và thay thế nó bằng một thứ khác ¶ Ghi chú:
Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 235
function foo() 8Có 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ỡ
"; unset($a); echo "The value of 'a' after unset: " . $a; ?>00 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>01 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>02 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>03 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>04 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>05 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>06 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>07 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>08 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>09 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>10 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>11 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>12 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>13 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>14 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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($a); echo "The value of 'a' after unset: " . $a; ?>16 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>17 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset: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. ¶ Ghi chú "; unset($a); echo "The value of 'a' after unset: " . $a; ?>19 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>20 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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. ¶ Không thể tháo gỡ "; unset($a); echo "The value of 'a' after unset: " . $a; ?>22 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>23 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>24 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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. ¶ Ghi chú "; unset($a); echo "The value of 'a' after unset: " . $a; ?>26 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>27 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>28 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>29 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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ú: "; unset($a); echo "The value of 'a' after unset: " . $a; ?>31 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>32 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>33 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>34 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 Không có giá trị được trả về. ¶ Xem thêm "; unset($a); echo "The value of 'a' after unset: " . $a; ?>36 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>37 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 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($a); echo "The value of 'a' after unset: " . $a; ?>39 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>40 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>41 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>42 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>43 Andreas ¶ ¶ 12 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>44 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>45 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>46 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>47 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>48 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>49 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>50 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>51 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>52 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>53 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>54 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>55 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>56 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 macnimble tại gmail dot com ¶ 13 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>58 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>59 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:9 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>61 Chad 0x40 Herballure 0x2e com ¶ ¶ 15 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>62 Tigercat tại Aol Dot Com ¶ ¶ 10 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>63 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>64 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 235 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>66 Muhamad_zakaria tại Yahoo Dot Com ¶ ¶ 17 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>67 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>68 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>69 Magiê dot oxit dot play+php tại gmail dot com ¶ ¶ 8 năm trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>70 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>71 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>72 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>73 Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 235 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>75 ray.paseur đôi khi sử dụng gmail ¶ ¶ 7 tháng trước "; unset($a); echo "The value of 'a' after unset: " . $a; ?>76 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>77 "; unset($a); echo "The value of 'a' after unset: " . $a; ?>78 The value of 'a' before unset: Welcome TutorialsPoint! The value of 'a' after unset:5 Unset () trong PHP là gì?unset () phá hủy các biến được chỉ định.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.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.destroys the specified variables. The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset() inside of a function, only the local variable is destroyed.
Chức năng nào được sử dụng để bỏ các biến trong PHP?Hàm unset () là một hàm sẵn có trong PHP được sử dụng để hủy bỏ một biến được chỉ định.unset() function is an inbuilt function in PHP which is used to unset a specified variable.
Điều gì xảy ra khi bạn sử dụng unset () để xóa giá trị khỏi một mảng?Hàm Untet được sử dụng để phá hủy bất kỳ biến nào khác và cùng cách sử dụng để xóa bất kỳ yếu tố nào của mảng.Lệnh Untet này lấy phím mảng làm đầu vào và loại bỏ phần tử đó khỏi mảng.Sau khi loại bỏ khóa và giá trị liên quan không thay đổi.After removal the associated key and value does not change.
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. |