I have a code for dynamic tree view using php mysql.
function fetchCategoryTreeList($parent = '', $user_tree_array = '')
{
// code here
}
i just want ...like. i have a variable
$top = '1234';
now how to put in this function like
function fetchCategoryTreeList($parent = $top, $user_tree_array = '')
{
// code here
}
if i put $top in this function then i got fatal error. Please help me
You cant assign default value as another variable to arguments. You can use constant instead
define("TOP", "1234");
function fetchCategoryTreeList($parent = TOP, $user_tree_array = '')
{
// code here
}
If you really need a default dynamic value :
$top = '1234' ;
// Some code
function fetchCategoryTreeList($parent = '', $user_tree_array = '')
{
global $top ;
if ( $parent == null || $parent == '' ) $parent = $top ;
// code here
}
But if the value is constant take a look at B Desai answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.