<分区>
我期待的输出是:
但实际输出是:""
$condition = true;
$categoryId = 123;
$result = 'http://domain.dev/category' . empty($condition) ? '' : '/' . $categoryId;
var_dump($result);
据我了解 - 它检查 empty($condition)
是否为空 - 如果为真,则将 http://domain.dev/category
附加到 ''
或者 else /$categoryId
我做错了什么?