当前位置:网站首页>Several functions in YAF framework controller
Several functions in YAF framework controller
2022-06-13 03:14:00 【wks19891215】
Recently in use yaf Write a demo, One scenario is to automatically jump to the login page when the user is not logged in .( Found behind yaf The Chinese manual also takes this as an example ,
)
First look forward Usage of :
if(!$login)
{
$this->forward(null,'login','index');
return false;
}
The first parameter is to jump moduel name , The following are controller and action The name of . In addition to these three parameters ,forward The fourth parameter is also supported ( Array ).
It should be noted that there must be return false End the current execution process . Otherwise, the frame will render the current view first , Then render the forwarding destination view . And the contents of the two views are stacked in one page .
Look again redirect:
if(!$login)
{
$this->redirect("/Login/index");
}One parameter function , The program redirects directly after the call . There is no need to manually end the current process .
The functions of the two functions are very similar , Guess the difference is redirect No data can be attached . and forward The fourth argument to is an array , Can forward key value pair data . Available for purpose controller Zhongyou $this->getRequest()->getParam() obtain .
Let's look at render and display:
render Is the default behavior of the framework . Its function is to just pre render , Does not immediately show .
and display Is a direct display view . But pay attention to one problem : Use up display after , Still need to be in the present action Return to one false, Otherwise, the framework will perform the default action ( That's it action Default rendered content ). It will cause the contents of two views to accumulate in one page .
边栏推荐
- C method parameter: ref
- Radium laser radar C16 data to PCD (based on ROS)
- English语法_方式副词-位置
- String: number of substring palindromes
- Capital digit to number format
- SQL execution process in MySQL (3)
- C simple understanding - overloaded operator
- Coordinate location interface of wechat applet (II) map plug-in
- Ijkplayer source code -- mnatemediaplayer of ijkmediaplayer
- Reading notes of effective managers
猜你喜欢

Radio design and implementation in IVI system

Prometheus install and register services

Review notes of RS data communication foundation STP

Spoon database insert table operation

Mp4 playback

Typical application of ACL

C simple understanding - generics

Es and kibana deployment and setup

C simple understanding - arrays and sets

Prometheus安装并注册服务
随机推荐
产品需求文档如何编写
Ijkplayer source code - setting options
MySQL index optimization (4)
Level II C preparation -- basic concepts of program design
Applet image component long press to identify supported codes
In my ten years, every bit has become a landscape?
IOS interview · full bat interview record of an IOS programmer (including the true interview questions of Baidu + Netease + Alibaba)
MySQL transactions and locks (V)
Prometheus安装并注册服务
[JVM series 8] overview of JVM knowledge points
Supervisor -- Process Manager
Prometheus install and register services
JMeter quick start
Reading notes of effective managers
Collection of IOS development interview and underlying learning videos
Querywrapper constructor method
When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
. New features in net 6.0 _ What's new in net 6.0
JVM class loader (2)
On the limit problem of compound function