Hướng dẫn how to unset post data in php - cách hủy đặt dữ liệu bài đăng trong php

Tôi có một trang gửi dữ liệu vào cơ sở dữ liệu và tôi muốn làm cho nó để nếu trang được làm mới, nó sẽ không gửi thông tin nữa. Tôi đang cố gắng sử dụng Unpet các biến để nếu trang được làm mới, nó sẽ không gửi lại. Tôi đã thấy một bài viết về việc thiết lập độ trễ thời gian của một cái gì đó như 30 giây, nhưng muốn chỉ để giải quyết biến. Tôi dường như không thể làm cho nó hoạt động. Đây là một đoạn của những gì tôi có:
so that if the page is refreshed, it doesn't submit the information
again. I am trying to use unset the variables so that if the page is
refreshed, it will not submit again. I saw a post about setting a time
delay of something like 30 seconds, but would prefer just to unset the
variable. I can't seem to get it working. Here is a snippet of what I
have:

echo 'tên đầu tiên:'. $ _ post ['first_name'];

if (isset ($ _ post ['first_name'])) {... Nếu nó được đặt, hãy gửi đến cơ sở dữ liệu} khác {echo 'không có dữ liệu để gửi. Để nhập một đề cử, bấm vào đây '; }
{
... if it is set, submit to the database
}
else
{
echo '

There is no data to submit. To enter a nomination, Click Here

';
}

unset ($ _ post ['first_name']);

echo 'tên đầu tiên:'. $ _ post ['first_name']; Echo đầu tiên hiển thị những gì đã được gửi trong biểu mẫu, lần thứ hai cho thấy biến trống. Khi tôi làm mới, $ _POST ['First_name'] chứa dữ liệu từ biểu mẫu.
The first echo displays what was submitted in the form, the second
shows that the variable is empty. When I refresh though,
$_POST['First_Name'] contains the data from the form again.

Ai đó có thể giải thích cách họ sẽ đảm bảo rằng khi một trang được làm mới, dữ liệu không được gửi lại hoặc giải thích cho tôi một cách để có được những gì tôi đã bắt đầu làm việc?
page is refreshed that data is not submitted again, or explain to me a
way to get what I have started working?

Lion_Cat tại Mail Ru ¶

13 năm trước

Dan at--nospam-- cubeland dot co dot uk ¶

Thorry tại Thorry Dot Net
$a = "Hello world!";
echo "The value of variable 'a' before unset: " . $a . "
";
unset($a);
echo "The value of variable 'a' after unset: " . $a;
?>

Pauljamescampbell tại Gmail Dot Com ¶


14 năm trước

Clark tại Everettsconsulting Dot Com ¶


Phpmanual tại Kennel17 Dot Co Dot Uk ¶

Tecdoc tại Ukr Dot Net ¶

6 tháng trướcẨn danh ¶
Lion_Cat tại Mail Ru ¶13 năm trước
Dan at--nospam-- cubeland dot co dot uk ¶Thorry tại Thorry Dot Net

Pauljamescampbell tại Gmail Dot Com ¶

14 năm trướcWarheog tại Warhog Dot Net
Edouard Dot Berge tại Gmail Dot Com ¶Warheog tại Warhog Dot Net
Edouard Dot Berge tại Gmail Dot Com ¶dibakar dot datta tại gmail dot com ¶

Lion_Cat tại Mail Ru ¶


Đội câu trả lời giáo dục

Hàm unset() trong PHP đặt lại bất kỳ biến nào. Nếu unset () được gọi bên trong hàm do người dùng xác định, nó sẽ giải quyết các biến cục bộ. Nếu người dùng muốn hủy bỏ biến toàn cầu bên trong hàm, thì anh ta/cô ta phải sử dụng mảng $GLOBALS để làm như vậy. Hàm unset() không có giá trị trả về.unset() function in PHP resets any variable. If unset() is called inside a user-defined function, it unsets the local variables. If a user wants to unset the global variable inside the function, then he/she has to use $GLOBALS array to do so. The unset() function has no return value.

Hình minh họa dưới đây giải thích cách một biến là unset():

Ví dụ

Mã 1

Ví dụ được mã hóa dưới đây giải quyết biến cục bộ:

<?php

$my_var='Hello User';

echo " before unset : ".$my_var;

echo"\n";

unset($my_var);

echo "after unset : " .$my_var;

?>

Mã 2

Ví dụ được mã hóa dưới đây sẽ giải quyết biến toàn cầu bằng cách sử dụng mảng $GLOBALS:

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

Lỗi trong mã xảy ra do mã cố gắng in biến không đặt.

Bản quyền © 2022 Giáo dục, Inc. Tất cả quyền được bảo lưu

Tecdoc tại Ukr Dot Net ¶

6 tháng trướcUnset a given variable

Ẩn danh ¶

Lion_Cat tại Mail Ru ¶unset() inside of a function can vary depending on what type of variable you are attempting to destroy.

13 năm trướcunset() 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.

<?php
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:

<?php
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.

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

0

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

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.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.

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

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

Thông số

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

2

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

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

3

Các biến tiếp theo.

Trả về giá trị

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

Ví dụ

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

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

4

Ví dụ #2 sử dụng

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

5 đúc

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

5 Pha đúc thường bị nhầm lẫn với hàm unset ().

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

5 đúc chỉ phục vụ như một diễn viên ____ 18 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.unset() function.

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

5 casting serves only as a

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

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.

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

9

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

Ghi chú

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.: Because this is a language construct and not a function, it cannot be called using variable functions, or named arguments.

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.

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.

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.unset() on inaccessible object properties, the __unset() overloading method will be called, if declared.

Không thể tháo gỡ Before unset: 1, after unset: 23 Before unset: 2, after unset: 23 Before unset: 3, after unset: 23 0 bên trong một phương thức đối tượng.

  • 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
  • __unset()
  • ISSET () - 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

Array_Splice () - Xóa một phần của mảng và thay thế nó bằng một thứ khác

(unset) Đúc

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

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

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

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

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

Hayley Watson ¶

9 năm trước

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

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

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

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

unset()0

Nox tại Oreigon Dot de ¶

9 năm trước

unset()1

unset()2

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

Nox tại Oreigon Dot de ¶

14 năm trước

unset()4

unset()5

unset()6

unset()7

Kai Kunstmann ¶

J dot vd dot merwe tại enovision dot net ¶

unset()8

unset()9

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

12 năm trước

Franckraynal tại miễn phí dot fr ¶

$GLOBALS1

$GLOBALS2

$GLOBALS3

$GLOBALS4

$GLOBALS5

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

17 năm trước

Andre at twg dot com dot au ¶

$GLOBALS7

$GLOBALS8

$GLOBALS9

unset()0

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

18 năm trước

Franckraynal tại miễn phí dot fr ¶

unset()2

unset()3

unset()4

unset()5

17 năm trước

Andre at twg dot com dot au ¶

unset()6

unset()7

unset()8

unset()9

unset()0

unset()1

unset()2

unset()3

unset()4

unset()5

unset()6

unset()7

unset()8

unset()9

$GLOBALS0

$GLOBALS1

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

18 năm trước

J dot vd dot merwe tại enovision dot net ¶

$GLOBALS3

$GLOBALS4

$GLOBALS5

$GLOBALS6

12 năm trước

14 năm trước

$GLOBALS7

$GLOBALS8

$GLOBALS9

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

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

Kai Kunstmann ¶

J dot vd dot merwe tại enovision dot net ¶

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

12 năm trước

Andre at twg dot com dot au ¶

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

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

$GLOBALS9

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

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

18 năm trước

Hessodreamy tại Gmail Dot Com ¶

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

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

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

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

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

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

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

15 năm trước

J dot vd dot merwe tại enovision dot net ¶

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

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

$GLOBALS5

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

12 năm trước

Franckraynal tại miễn phí dot fr ¶

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

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

00

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

01

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

02

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

03

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

04

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

05

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

06

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

07

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

08

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

09

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

10

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

11

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

12

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

13

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

14

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

17 năm trước

9 năm trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

16

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

17

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

12 năm trước

14 năm trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

19

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

20

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

Kai Kunstmann ¶

Franckraynal tại miễn phí dot fr ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

22

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

23

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

24

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

17 năm trước

14 năm trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

26

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

27

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

28

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

29

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

Kai Kunstmann ¶

J dot vd dot merwe tại enovision dot net ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

31

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

32

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

33

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

34

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

Array_Splice () - Xóa một phần của mảng và thay thế nó bằng một thứ khác

Andre at twg dot com dot au ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

36

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

37

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

18 năm trước

9 năm trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

39

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

40

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

41

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

42

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

43

Nox tại Oreigon Dot de ¶

14 năm trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

44

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

45

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

46

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

47

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

48

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

49

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

50

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

51

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

52

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

53

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

54

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

55

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

56

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

Kai Kunstmann ¶

Hessodreamy tại Gmail Dot Com ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

58

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

59

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

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

61

15 năm trước

Andre at twg dot com dot au ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

62

18 năm trước

Hessodreamy tại Gmail Dot Com ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

63

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

64

$GLOBALS5

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

66

15 năm trước

J dot vd dot merwe tại enovision dot net ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

67

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

68

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

69

12 năm trước

Franckraynal tại miễn phí dot fr ¶

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

70

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

71

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

72

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

73

$GLOBALS5

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

75

ray.paseur đôi khi sử dụng gmail ¶

7 tháng trước

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

76

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

77

<?php

$my_var='Hello User';

function unset_var()

{

global $my_var;

echo "Before unset and inside function : ".$my_var."\n";

unset($GLOBALS['my_var']);

}

echo "Outside function before using function : ".$my_var."\n";

unset_var();

echo "Outside function after using function : ".$my_var."\n";

?>

78

Before unset: 1, after unset: 23
Before unset: 2, after unset: 23
Before unset: 3, after unset: 23
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.

Làm thế nào chúng ta có thể bỏ các biến trong PHP?

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

Làm thế nào để bạn sử dụng unset?

Hàm unset () trong PHP đặt lại bất kỳ biến nào.Nếu unset () được gọi bên trong hàm do người dùng xác định, nó sẽ giải quyết các biến cục bộ.Nếu người dùng muốn hủy bỏ biến toàn cầu bên trong hàm, thì anh ta/cô ta phải sử dụng mảng toàn cầu để làm như vậy.Hàm unset () không có giá trị trả về.If unset() is called inside a user-defined function, it unsets the local variables. If a user wants to unset the global variable inside the function, then he/she has to use $GLOBALS array to do so. The unset() function has no return value.

Undet ($ foo làm gì trong PHP?

Hàm unset () phá hủy các biến được chỉ định.destroys the specified variables.