User Tools

Site Tools


uphp:functions:isset

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
uphp:functions:isset [2017/03/10 13:53]
jeff created
uphp:functions:isset [2021/09/13 05:57] (current)
Line 1: Line 1:
 ======isset====== ======isset======
 +
 <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> <badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge>
  
-Return 1 if the variable exists+Check if variable exists
  
 ====Description==== ====Description====
-<well size="sm"><html><span style="font-size:125%;color:green;">int + 
-<span style="color:black;"></html>[[isset]] +<well size="sm"><html> 
-<html>+<span style="font-size:125%;color:green">int 
-<span style="color:green;">mixed +<span style="color:black">isset ( 
-<span style="color:blue;">$variable +<span style="color:green">mixed 
-<span style="color:black;">)+<span style="color:blue">$variable 
 +<span style="color:black">)
 </html></well> </html></well>
  
 Determine if a variable is set Determine if a variable is set
  
-====Parameters==== +====Parameter====
-<html><span style="color:blue;"><b>variable</b><span style="color:black;"></html>:  Variable to check for existence((Multiple parameters are not supported as in mainline PHP))+
  
-====Return Value==== +<html><b><span style="color:blue">$variable<span style="color:black"></b></html>:  Variable to check for existence((Multiple parameters are not supported as in mainline PHP))
-(true) if variable exists, 0 (falseif variable does not exist+
  
-====Examples==== +====Return Values====
-<code php> +
-<? +
-print(isset($x)); //outputs 0, the variable doesn't exist yet +
-$x=0; +
-print(isset($x)); //outputs 1+
  
-$y=''; +<html><b><span style="color:green">Integer<span style="color:black"></b></html>:  (true) if variable exists(falseif variable does not exist
-print(isset($y)); //outputs 1, $y exists (although it is an empty string)+
  
-$z=chr(0); +====Examples====
-print(isset($z)); //outputs 1, $z exists with a single character (ASCII code 0 or NUL)+
  
-$array=array(); +<code php> 
-print(isset($array)); //outputs 1, $array exists (an empty array) +<? 
- +  print(isset($x)); // outputs 0, the variable doesn't exist yet 
-$array[1]="test"; +  $x=0; 
-print(isset($array[0])); //outputs 0, the first element in the array does not exist +  print(isset($x)); // outputs 1 
-print(isset($array[1])); //outputs 1, the second element in the array exists+   
 +  $y=''; 
 +  print(isset($y)); // outputs 1, $y exists (although it is an empty string) 
 +   
 +  $z=chr(0); 
 +  print(isset($z)); // outputs 1, $z exists with a single character (ASCII code 0 or NUL) 
 +   
 +  $array=array(); 
 +  print(isset($array)); // outputs 1, $array exists (an empty array) 
 +   
 +  $array[1]="test"; 
 +  print(isset($array[0])); // outputs 0, the first element in the array does not exist 
 +  print(isset($array[1])); // outputs 1, the second element in the array exists
 ?> ?>
 </code> </code>
Line 45: Line 50:
 ====Notes==== ====Notes====
  
-There is no way to unset a variable once it has been set (except to exit the local scope or script where it was defined). Unlike mainline PHP, uPHP does not have a construct ''unset()'' or the constant ''null''. Unlike many other programming languages, you cannot simply remove a variable by setting it equal to nothing, such as by trying the statement ''$x=;''((As tested on a Wattmon Pro with firmware 1.1051 the statement ''$x=;'' causes a Watchdog Timeout error and a reboot of the Wattmon)).+There is no way to unset a variable once it has been set (except to exit the local scope or script where it was defined). Unlike mainline PHP, uPHP does not have a construct ''unset()'' or the constant ''null''. Unlike many other programming languages, you cannot simply remove a variable by setting it equal to nothing, such as by trying the statement ''$x=;''((As tested on a [[hardware:wattmons:WattmonPRO]] with firmware 1.1051 the statement ''$x=;'' causes a Watchdog Timeout error and a reboot of the Wattmon)).
  
 Also note that the uPHP [[isset()]] does not always generate a parsing error if the parameter is not a variable((See http://php.net/manual/en/function.isset.php where it says "Warning: isset() only works with variables as passing anything else will result in a parse error.")). All of these examples will return 0: Also note that the uPHP [[isset()]] does not always generate a parsing error if the parameter is not a variable((See http://php.net/manual/en/function.isset.php where it says "Warning: isset() only works with variables as passing anything else will result in a parse error.")). All of these examples will return 0:
Line 51: Line 56:
 <code php> <code php>
 <? <?
-print(isset(1)); +  print(isset(1)); 
-print(isset("123")); +  print(isset("123")); 
-print(isset(array(1,2,3))); +  print(isset(array(1,2,3))); 
-print(isset(2+3));+  print(isset(2+3));
 ?> ?>
 </code> </code>
Line 62: Line 67:
 <code php> <code php>
 <? <?
-print(isset(z));+  print(isset(z));
 ?> ?>
 </code> </code>
Line 75: Line 80:
  
 ====See Also==== ====See Also====
-[[is_int()]] - Return 1 if the variable is an integer 
  
-[[is_float()]] - Return 1 if the variable is a float+[[is_int()]] - Check if a variable is an <html><b><span style="color:green">integer<span style="color:black"></b></html> 
 + 
 +[[is_float()]] - Check if variable is a <html><b><span style="color:green">float<span style="color:black"></b></html>
  
-[[is_numeric()]] - Return 1 if the value is numeric (integer, float or numeric string)+[[is_numeric()]] - <html>Check if value is numeric (<b><span style="color:green">int<span style="color:black"></b><b><span style="color:green">float<span style="color:black"></b> or numeric <b><span style="color:green">string<span style="color:black"></b>)</html>
  
-[[is_array()]] - Return 1 if the variable is an array+[[is_array()]] - Check if variable is an <html><b><span style="color:green">array<span style="color:black"></b></html>
  
-[[is_string()]] - Return 1 if the variable is a string+[[is_string()]] - Check if variable is a <html><b><span style="color:green">string<span style="color:black"></b></html>
  
 [[uphp:variables|uPHP Variable Types and Limits]] [[uphp:variables|uPHP Variable Types and Limits]]
  
uphp/functions/isset.1489154034.txt.gz · Last modified: 2021/09/13 05:56 (external edit)