How to view the contents of a variable
There is a var_dump ($var) function in PhP4 that dumps the contents of a variable (variables of various types), except that the output of this function is not suitable for display in an HTML page. You can write a function like this:
function Dump ($var) {
echo "
";
Var_dump ($var);
echo "
";
}
Great for commissioning!
In PhP3, you can only use recursive method to dump the contents of an array, there is nothing for object. As if the Dump_array function of the previous article is such a function. :)
Second, static variables
function test ()
{
Static $s _val;
$s _val+=2;
return $s _val;
}
echo Test ();//2
echo Test ();//4
?>
Iii. a method of avoiding multiple occurrences with celebrities
#----------------Avoid the same name-------------
for ($checkname =0; $checkname < $num; $checkname + +)
{
if ($name [$checkname]== $name [$num])
{
$num--;
Break
}
}
Iv. Obtaining an extension of a file
With this small function you can:
function Fileextname ($filename)
{
$retval = "";
$pt =strrpos ($filename, ".");
if ($pt) $retval =substr ($filename, $pt +1, strlen ($filename)-$pt);
return ($retval);
http://www.bkjia.com/PHPjc/532195.html www.bkjia.com true http://www.bkjia.com/PHPjc/532195.html techarticle How to view variable contents there is a var_dump ($var) function in PhP4 to dump the contents of a variable (various types of variables), except that the output of this function is not suitable for the HTML page ...