Set http status codes using the Response class.
In this table you'll find information about the different methods you can use and what kind of data can be passed as an argument.
Method | Arg | Type | Expect |
---|---|---|---|
get() | 1 | string | int | http status code |
statusCode() | 1 | string | int | http status code |
Setting a http response status code using the set function method.
<?php
namespace app\controllers;
use core\http\Response;
class ExampleController extends Controller {
public function example() {
return Response::set(200);
}
}
Setting a http response status code while returning a view.
<?php
namespace app\controllers;
use core\http\Response;
class ExampleController extends Controller {
public function example() {
return Response::statusCode(404)->view('/404/404')->data();
}
}