Home > Backend Development > PHP Tutorial > 跪求php大侠,不懂可以帮忙顶下解决思路

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

WBOY
Release: 2016-06-13 13:41:32
Original
770 people have browsed it

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

现在类中的code

PHP code
<!--

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为数据库操作类
        
    }
    
}

Copy after login

控制器中【__control.php】的
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
public function default_action(){
        $hr = new HR;
        $empid = "S0001";
        [color=#FF0000]$info = $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]
Copy after login
{
$this->page->add($key,$item);
}
}
$this->page->name=$tpl;
if($return){
return $this->page->fetch();
}else{
$this->page->show();
}
}
[/code]

我页面如何去数据啊【.tpl中】????
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<div class="sContent">
    <dl>
        <dt>员工流水号</dt>
        <dd><ul><li><a href>[/color]a></a></li></ul></dd>
    </dl>
    <dl>
        <dt>昵称</dt>
        <dd>[/color]dd>
    </dd>
</dl>
</div>

Copy after login


------解决方案--------------------
mvc都是以struct等形式传数据的。
------解决方案--------------------
数组要pirnt_r或者var_dump.
------解决方案--------------------
PHP code
<?php print <<<EOT
<div class="sContent">
    
Copy after login
员工流水号
昵称
[/color]dd>
EOT; ?>
------解决方案--------------------
你是用的smarty,还是自己手动写的模板呢?
------解决方案--------------------
你只给出了代码片段,无法做测试

请说明你遇到了什么问题

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template