• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

跪求php大侠,不懂可以帮忙顶下解决思路

php 搞代码 4年前 (2022-01-24) 19次浏览 已收录 0个评论

跪求php大侠,不懂可以帮忙顶下
php中将业务处理跟逻辑区分开,分别由这些control,tpl,php共同实现一个页面!!!

现在类中的code

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->class HR {    function __construct(){}    public static function get_emp_list($cid){//我一般用静态函数                return DB::getAll('select * from erp_employee where cid='.DB::quote($cid));        //DB为数据库操作类            }    }

控制器中【__control.php】的

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->public function default_action(){        $hr = new HR;        $empid = "S0001";        [color=#FF0000]$info <strong style="color:transparent">9来源gaodai#ma#com搞@代~码$网</strong>搞gaodaima代码= $hr->get_emp_list($empid);[/color]  //[[color=#0000FF]这个怎么知道Info里有啥啊[/color]?]                $args=array('arg1' => $empid,'arg2' => 'aaaaaaaaa');        //$args['empinfo'] = $info;        $this->show_page('index',$args);            }        public function show_page($tpl,$data=null,$return=false){        if(!is_null($data) && is_array($data)){            foreach($data as $key=>$item)[code=PHP]

{
$this->page->add($key,$item);
}
}
$this->page->name=$tpl;
if($return){
return $this->page->fetch();
}else{
$this->page->show();
}
}
[/code]

我页面如何去数据啊【.tpl中】????

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><div class="sContent">    <dl>        <dt>员工流水号</dt>        <dd><ul><li></li></ul></dd>    </dl>    <dl>        <dt>昵称</dt>        <dd>    </dl></div>

——解决方案——————–
mvc都是以struct等形式传数据的。
——解决方案——————–
数组要pirnt_r或者var_dump.
——解决方案——————–

PHP code

<?phpprint <<<EOT

员工流水号
昵称

EOT;?>
------解决方案--------------------
你是用的smarty,还是自己手动写的模板呢?
------解决方案--------------------
你只给出了代码片段,无法做测试

请说明你遇到了什么问题


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:跪求php大侠,不懂可以帮忙顶下解决思路

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址