본문 바로가기

php

unset 함수

unset()은 주어진 변수를 파괴합니다.

함수 안에서 unset()의 행동은 어떠한 변수를 제거하려 하는지에 따라 달라집니다.

함수 안에서 전역 변수를 unset()하면, 로컬 변수만 파괴됩니다. 호출한 환경에서 변수는 unset()을 호출하기 전과 같은 값을 유지합니다.


 <?php

function destroy_foo()
{
    global 
$foo;
    unset(
$foo);
}

$foo 'bar';
destroy_foo();
echo 
$foo;
?>


'php' 카테고리의 다른 글

PHP PDO의 소개와 기본 다지기  (0) 2018.10.07
UTF-8에서 EUC-KR로 변경하기  (0) 2013.10.25
조회날짜 변환 ㅎㅎ  (0) 2013.10.24
php 에러표시여부  (0) 2013.07.24
Deprecated: Function session_unregister() is deprecated  (0) 2013.07.04