Home >Backend Development >PHP Tutorial >How to correctly implement PHP function function expansion_PHP tutorial
In this article we will give you a detailed introduction to the code example of
PHP function extension:
In the calling page, it is often $tmp=choose($name,$id,$task);
Another PHP function function expansion method is:
<ol class="dp-xml"><li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>function choose($name,$id,<br />$task,$</span><span class="attribute">instance</span><span>=</span><span class="attribute-value">0</span><span>){ </span></li><li class="alt"><span>global $db_link; </span></li><li><span>..... </span></li><li class="alt"><span>return $xx; </span></li><li><span>} </span></li><li class="alt"><span class="tag">?></span><span> </span></span></li></ol>
The use of this function is the same as usual, except when we do not pass in $instance, such as
$array=choose($name,$id,$task);
It is handled by the default $instance=0. When we need $instance to expand the PHP function, the page we call can be written like this:
$instance="..." ;
$array=choose($name,$id,$task,$instance)