V
V
Viktor Volkov2018-03-21 10:52:20
PHP
Viktor Volkov, 2018-03-21 10:52:20

What is this design?

I mean the design itself, the components are clear.
$this->params = $url ? array_values($url) : [];

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Sklyarov, 2018-03-21
@VGVolkov

This is the same as:

if($url) {
$this->params = array_values($url);
} else {
$this->params = [];
}

Shorthand for if conditions: (expression) ? true : false;
You can browse here: https://davidwalsh.name/php-ternary-examples

M
Maxim, 2018-03-21
@Mx21

Ternary operator.

M
Maxim Osadchy, 2018-03-21
@waspmax1

Alternative if else syntax
If $this->params = $url - return array_values($url), otherwise - empty array

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question