当前位置:Gxlcms > PHP教程 > php-PHP一个方法根据传递值怎么执行多次?

php-PHP一个方法根据传递值怎么执行多次?

时间:2021-07-01 10:21:17 帮助过:1人阅读

phpjavascript数据

php代码

 function one($type='OfferGetAllOfferList',$start,$pagesize=10,$total=100)    {        $next=$start+1;        if($start*$pagesize<=$total)        {            $this->outData['next'] = $next;            $this->outData['pagesize'] = $pagesize;            $this->outData['type'] = $type;            $this->outData['total'] = $total;            $this->output();        }        elseif($type == 'OfferGetAllOfferList' && $start*$pagesize>$total)        {               $this->outData['next'] = $next;            $this->outData['pagesize'] = $pagesize;            $this->outData['type'] = 'TradeOrderListGet';            $this->outData['total'] = $total;            $this->output();        }elseif($type == 'TradeOrderListGet' && $start*$pagesize>$total)        {               $this->outData['next'] = $next;            $this->outData['pagesize'] = $pagesize;            $this->outData['type'] = 'MemberGet';            $this->outData['total'] = $total;            $this->output();        }else        {            echo "同步完成";            exit;        }    }


js代码

 

问题:
$type默认是OfferGetAllOfferList,当$start*$pagesize大于100时执行elseif($type == 'OfferGetAllOfferList' && $start*$pagesize>$total)里面的代码,$start归1。
$start*$pagesize大于100时执行elseif($type == 'TradeOrderListGet' && $start*$pagesize>$total)里面的代码,结果归1。
最后输出“同步完成”。
遇到的问题就是第一个if执行完怎么把$start归1继续往底下执行?

人气教程排行