Comments (2)
Controller
namespace app\controller;
use yii\web\Controller;
class HelloController extends Controller {
public function actionIndex(){
echo 'hi';
}
}
请求组件
$request = \YII: $app-> request;
$request = request -> get('id'); //获取url里面id参数 get方式
$request = request -> post('id'); //获取url里面id参数 post方式
if( $request -> isGet) //判断是否为get方式
api [http://www.yiichina.com/doc/api/2.0/yii-web-request ]
响应组件
$res = \YII::$app->response;
$res->statusCode = '400';
$res->headers->add('prama','no-cache');
$this->redirect('http://www.baidu.com');//重定向
$res->headers->add('content-disposition',''attachment;filename="a.png"');//下载文件
$res->sendFile('./test.txt');//下载文件
session
$session = \YII:$app->session;
$session->open();
if($session->isActive); //是否开启
$session->set(key,value);
$session->get(key)
cookies
$cookies = \YII:$app->respones->cookies;
//设置
$data = array('name'=>‘user’,'value'=>'test');
$cookies -> add(key,value);
$cookies->remove('id');
获取cookies
$cookies = \YII::$app->request->cookies;
$cookies->getValue('user');
from blog.
视图
return $this - >renderPartial('index.php')//渲染视图
$this->rend('index');//
from blog.
Related Issues (20)
- 函数式编程记录 HOT 2
- VUE MVVM原理和实现 HOT 2
- Vue Router原理和实现
- React Redux源码
- [php] mysql HOT 1
- [php] yii2 mysql HOT 2
- redux react-redux HOT 3
- 常用mysql
- [webpack ]多项目入口改造 HOT 7
- [linux] 内存清理
- lnmp服务器常见问题收集
- **所有城市经纬度坐标json以及对应的省市县3级联动json HOT 1
- 翻墙
- [linux] 日常记录
- pwa HOT 2
- 缓存一些记录 HOT 2
- npm HOT 1
- echarts 一些用法
- webpack 打包优化 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blog.