Kneel beg PHP Warrior, do not understand can help top down
In PHP, the business process is separated from the logical zone, which is implemented by these control,tpl,php together to achieve a page!!!
The code in the class now
PHP Code
Class HR { function __construct () {} public static function Get_emp_list ($CID) {//I typically return DB with static functions :: GetAll (' select * from Erp_employee where cid= '. Db::quote ($cid)); DB is the database operation class } }
"__control.php" in the controller.
PHP Code
Public Function default_action () { $hr = new hr; $empid = "S0001"; [color= #FF0000] $info = $hr->get_emp_list ($empid); [/color] [[color= #0000FF] How does this know what's in 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]
My page how to go to the data ah ". TPL"????
PHP Code
-
Employee Serial Number
-
-
Nickname
<{$arg 2}>
------Solution--------------------
MVC spreads data in the form of structs.
------Solution--------------------
Arrays are Pirnt_r or var_dump.
------Solution--------------------
PHP Code
-
Employee Serial Number
-
-
Nickname
<{$arg 2}>
EOT;? >
------Solution--------------------
Do you use the smarty, or do you manually write the template?
------Solution--------------------
You just gave the code snippet and couldn't do the test.
Please indicate what problem you have encountered.