Вероломство
не могу понять я её
вот массив
Код (Text):
array (size=3) ‘module’ => string ‘guest’ (length=6) ‘controller’ => string ‘Home’ (length=4) ‘action’ => string ‘index’ (length=5)вот он прилетел в конструктор
PHP:
public function __construct($route) { }отлуп: Undefined offset: 0
поясните, что я не так делаю
mkramer
https://www.php.net/manual/ru/function.list.php#example-5480
miketomlin
MouseZver
PHP:
<?php class foo { public function __construct ( $route ) { [ ‘module’ => $this -> module, ‘controller’ => $this -> controller, ‘action’ => $this -> view ] = $route; } } ‘module’ => ‘guest’, ‘controller’ => ‘Home’, ‘action’ => ‘index’ ] ) );В PHP8 еще интереснее.
Вероломство
а где $this->view = ‘index’ ($route[‘action ‘])?
короче я запутался и сделал так
PHP:
public function __construct($route) { foreach ($route as $name => $value) { $this->{$name == ‘action’ ? ‘view’ : $name} = $value; } }ерунда какая-то — эта list()
MouseZver
смотри лучше
Вероломство
надо паузу сделать
а то с первого раза чёт не зашло …