[英]create dynamic tree using php
I have a code for dynamic tree view using php mysql. 我有一个使用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. 如果我将$ top放在此函数中,则会出现致命错误。 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. 但是,如果该值恒定,请看一下B Desai的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.