php mvc 框架演示
2016-03-31 15:52
519 查看
<pre name="code" class="cpp"><pre name="code" class="python">tpl: class EnvAction extends Action 类 EnvAction 继承Action类 class EnvAction extends Action { // class Index extends Action { public function index(){ // $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8'); echo helloworldaaaaaaa; $name="赵杨健"; $this->assign('data',$name); $this->display(); } public function env(){ $m=new Model('machine_info'); //传入表名 $arr=$m->select(); var_dump($arr); } $this->display(); 输出的内容存放的位置: 需要在C:\wamp\www\thinkphp\Home\Tpl\ 下创建Env(模块名)目录 在类名目录下创建方法名.html env.html <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <h1>helloworld {$data}</h1> </body> </html> 通过C 调用V层模板 V层模板数据调用M层来获取数据 M mod类文件 负责对数据的操作 项目目录/应用目录/Lib/Model C 功能模块 编写类文件 项目目录/应用目录/Lib/Action V 负责页面呈现 编写模板文件 html文件 对应thinkphp 项目目录下/应用目录 Home/Tpl <?php return array( 'DB_TYPE'=>'mysql', 'DB_HOST'=>'192.168.32.79', 'DB_NAME'=>'devops', 'DB_USER'=>'root', 'DB_PWD'=>'1234567', 'DB_port'=>'3306', 'DB_PREFIX'=>'', ); ?>
相关文章推荐
- php mvc 框架演示
- phpcms文件目录结构
- PHP操作FTP类 (上传、下载、移动、创建等)
- php获取本机真实IP地址实例代码
- laravel中的Contracts, ServiceContainer, ServiceProvider, Facades关系
- Php pdo链接access数据库并循环显示数据
- 【转】PHP的Trait 特性
- thinkPHP上传到服务器显示500错误
- 去除phpcms会员登录后头部登陆条的会员名称的括号
- PDO中获取结果集
- php发送邮箱简单教程
- php csrf防御
- ubuntu安装PHP5.6
- ThinkPHP3.2.3集成xheditor上传图片
- 详解PHP的Yii框架中自带的前端资源包的使用
- web、ftp上传区别
- Yii 表单验证规则---总结
- header("location:index.php");
- ubuntu卸载php
- PHP生成随机密码的4种方法及性能对比