I'm looking to practice chaining methods in PHP.
I want to use the following code to return the
Код: Выделить всё
$_SERVER['REQUEST_METHOD']index.php
Код: Выделить всё
use App\Request; $request = new Request; echo $request->server->get('REQUEST_METHOD'); Request.php
Код: Выделить всё
namespace App; class Request { public function server() { $key = $this->key; return $_SERVER[$key]; } public function get(string $key) { $this->key = $key; return $this; } } Источник: https://stackoverflow.com/questions/781 ... ods-in-php
Мобильная версия