為什么代碼在 class類下就實(shí)現(xiàn)不了遞歸呢?
????private?$tree?=?[]; ???? ????public?function?diggn($pid=0,$span?=?0){ ????????$span?+=?2; ????????$sql?=?"SELECT?*?from?`car_deepclassify`?where?`pid`?=?{$pid}?order?by?`createtime`?desc"; ????????$results?=?$this->db->query($sql)->result_array(); ????????//?var_dump($_POST);exit; ????????foreach?($results?as?$key?=>?$result)?{ ????????????//?$result['catename']?=? ????????????$send?=?$this->db->where('id',$result['id'])->get('car_deepclassify')->row_array(); ????????????$send['catename']?=?str_repeat(' ',$span).'|--'.$result['catename']; ????????????$this->tree[]?=?$send; ????????????$this->diggn($result['id'],$span); ????????} ????} ????public?function?diguiceshi(){ ????????$this->diggn(); ????????echo?'<pre>'; ????????print_r($this->tree); ????????echo?'</pre>'; ????}
像老師那樣為啥實(shí)現(xiàn)不了 ,只能這樣實(shí)現(xiàn)呢???(框架ci)
2018-04-08
在框架里面只能寫入方法里再調(diào)用?。≈v師那個(gè)是基本的php文件操作格式
class>public>function>obj