I expected the output to be:
http://domain.dev/category/123
But the actual conclusion: ""
$condition = true;
$categoryId = 123;
$result = 'http://domain.dev/category' . empty($condition) ? '' : '/' . $categoryId;
var_dump($result);
From what I understand - it checks if it is empty($condition)
empty - if true, add http://domain.dev/category
using ''
OR else/$categoryId
What have I done wrong?
source
share