12 Jan 2016

[Phalcon 2]11. Chuyển module trong phalcon| Phalcon response redirect

Chuyển module/ điều hướng trong phalcon

Lệnh forward chỉ sử dụng trong cùng module không có tác dụng chuyển sang module khác:
Khi chuyển từ module này sang module khác trong phalcon phải sử dụng
<?php
$response = new Response ();// của class Phalcon\Http\Response;
// Redirect to the default URI
$response->redirect(); // tới trang mặc định

// Redirect to the local base URI
$response->redirect("posts/index"); // tới đường dẫn của cùng website

// Redirect to an external URL
$response->redirect("http://en.wikipedia.org", true); // tới đường dẫn bên ngoài

// Redirect specifying the HTTP status code
$response->redirect("http://www.example.com/new-location", true, 301); 
// đường dẫn với code mong muốn
Chuyển module nếu không hoạt động sử dụng
return $response->redirect('/: module/:controller/:action/:param');

No comments:

Post a Comment

hocphalcon.blogspot.com