php包含字符串到isset

I am using the cakephp framework I am passing some variables into the url for pagination. I wish to include a string and join a isset

$this->Paginator->options(array('url' => array(isset($filterCompany)? $filterCompany : 'all'));

what I need is to include 'company:' before the isset

$this->Paginator->options(array('url' => array('company:'.isset($filterCompany)? $filterCompany : 'all'));

I get an error (unidentified variable $filterCompany) with this, what would be the correct shorthand way?

Try this instead

$this->Paginator->options(array('url' => array('company'=> isset($filterCompany)? $filterCompany : 'all')));

You were trying to concatenate the result of ternary operator in a improper way.

The problem is that the concatenation is done before the comparison, so you are checking a string into the ternary operator, so you get true and $filterCompany is returned.

You can fix is using parenthesis:

$this->Paginator->options(array('url' => array('company:' . (isset($filterCompany)? $filterCompany : 'all')));