<?php
function name_by_user ( $arg1, $arg2, ..., $argN )
{
PROCEDURE
return $retval;
}
where,
$arg1, $arg2, ..., $argN = LIST OF ARGUMENTS
REQUIRED TO IMPLEMENT PROCEDURE
variable number of arguments
and default arguments are supported
name_by_user = NAME OF THE FUNCTION
PROVIDED BY THE USER
CASE SENSITIVE
PROCEDURE = Any valid PHP code
used to fulfill a particular purpose
$retval = VALUE RETURNED BY THE FUNCTION
?>
[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
a function: isstring -> user-defined
to display if the variable
is a STRING
- - - - - - - - - - - - - - - - - - - - - - - */
$var01a = $_SERVER['REMOTE_ADDR'];
$var01b = $_SERVER['HTTP_USER_AGENT'];
$var01c = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var01d = M_E;
$var01e = 1.6e-19;
$var01f = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$var01g = NULL;
function isstring($var)
{
if(is_string($var))
echo $var . '<br>is a STRING!<br><br>';
else
{
var_dump($var);
echo '<br>is NOT a STRING!<br><br>';
}
}
isstring($var01a);
isstring($var01b);
isstring($var01c);
isstring($var01d);
isstring($var01e);
isstring($var01f);
isstring($var01g);
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
a function: ISbool -> user-defined
to display if the variable
is a BOOLEAN value
- - - - - - - - - - - - - - - - - - - - - - - */
function ISbool ($var)
{
if(is_bool($var))
{
var_dump($var);
echo '<br>is a BOOLEAN value!<br><br>';
}
else
{
var_dump($var);
echo '<br>is NOT a BOOLEAN value!<br><br>';
}
}
$v01 = $_SERVER['REMOTE_ADDR'];
$v02 = $_SERVER['HTTP_USER_AGENT'];
$v03 = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$v04 = M_E;
$v05 = 1.6e-19;
$v06 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$v07 = NULL;
$v08 = false;
$v09 = FALSE;
$v10 = true;
$v11 = TRUE;
ISbool($v01);
ISbool($v02);
ISbool($v03);
ISbool($v04);
ISbool($v05);
ISbool($v06);
ISbool($v07);
ISbool($v08);
ISbool($v09);
ISbool($v10);
ISbool($v11);
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
a function: ISnull -> user-defined
to display if the variable
is a NULL value
- - - - - - - - - - - - - - - - - - - - - - - */
$var03a = $_SERVER['REMOTE_ADDR'];
$var03b = $_SERVER['HTTP_USER_AGENT'];
$var03c = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var03d = M_E;
$var03e = 1.6e-19;
$var03f = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$var03g = NULL;
function ISnull($var)
{
if(is_null($var))
echo $var . '<br>is a NULL value!<br><br>';
else
{
var_dump($var);
echo '<br>is NOT a NULL value!<br><br>';
}
}
ISnull($var03a);
ISnull($var03b);
ISnull($var03c);
ISnull($var03d);
ISnull($var03e);
ISnull($var03f);
ISnull($var03g);
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
a function: isnumeric -> user-defined
to display if the variable
is NUMERIC
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$var04a = $_SERVER['REMOTE_ADDR'];
$var04b = $_SERVER['HTTP_USER_AGENT'];
$var04c = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var04d = M_E;
$var04e = 1.6e-19;
$var04f = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$var04g = NULL;
function isnumeric($var)
{
if(is_numeric($var))
{
echo $var . '<br>is a NUMERC value!<br><br>';
}
else
{
var_dump($var);
echo '<br>is NOT a NUMERIC value!<br><br>';
}
}
isnumeric($var04a);
isnumeric($var04b);
isnumeric($var04c);
isnumeric($var04d);
isnumeric($var04e);
isnumeric($var04f);
isnumeric($var04g);
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The is_nan function accepts
only FLOAT NUMBER as a parameter.
If this is not taken into account,
Warning or a Fatal error
will be issued.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
function isnan ($par)
{
if (is_nan($par) == TRUE)
{
var_dump($par);
echo '<br>"Variable IS NOT a number"<br><br>';
}
else
{
var_dump($par);
echo '<br><br><br>';
}
}
$a = acos(3);
isnan($a);
isnan(M_E);
$var05e = 1.6e-19;
isnan($var05e);
$arr05 = [ 2, 4, 6 ];
isnan($arr05);
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
a function: isarray -> user-defined
to display if the variable
is ARRAY
- - - - - - - - - - - - - - - - - - - - - - - */
$var06a = $_SERVER['REMOTE_ADDR'];
$var06b = $_SERVER['HTTP_USER_AGENT'];
$var06c = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var06d = M_E;
$var06e = 1.6e-19;
$var06f = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$var06g = NULL;
$var06if = false;
$var06iF = FALSE;
$var06jt = true;
$var06jT = TRUE;
function isarray($var)
{
if(is_array($var))
{
var_dump($var);
echo '<br>This variable is an ARRAY!<br><br>';
}
else
{
var_dump($var);
echo '<br>This variable is NOT an ARRAY!<br><br>';
}
}
isarray($var06a);
isarray($var06b);
isarray($var06c);
isarray($var06d);
isarray($var06e);
isarray($var06f);
isarray($var06g);
isarray($var06if);
isarray($var06jT);
?>