PHP/Language Basics/Variable Set Unset — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:05, 26 мая 2010
Содержание
IsSet variable
<source lang="html4strict">
<?
$MyVar="Hello there!";
If(IsSet($MyVar)) echo "The variable is set. Its value is $MyVar";
?>
</source>
The isset() Function
<source lang="html4strict">
<html> <head>
<title>Isset()</title>
</head> <body> <?php
$my_var = 100; if(isset($my_var)) { print("\$my_var is set... the value is " . $my_var); } print("
"); print(isset($some_var) . "
"); $some_var = "I am set"; print(isset($some_var) . "
");
?> </body> </html>
</source>
UnSet array element
<source lang="html4strict">
<?
$A=array(0=>"zzzz", "a"=>"aaa", "b"=>"bbb", "c"=>"ccc"); Unset($A["a"]); echo $A["a"]
?>
</source>
unset() Function
<source lang="html4strict">
<html> <head>
<title>Unset()</title>
</head> <body> <?php
$authorJ = "A"; $authorC = "B"; $jeremy = &$authorJ; $charlie = &$authorC; print("$authorJ
"); unset($jeremy); print($authorJ . " or " . $jeremy . "
"); print("$authorC
"); unset($charlie); unset($authorC); print($authorC);
?> </body> </html>
</source>
Unset variable
<source lang="html4strict">
<?
$a="Hello there!"; echo $a unset($a); echo $a; // Error: there is no variable $a
?>
</source>