简体   繁体   中英

ErrorException Trying to get property of non-object

I've trying to set a variable depending on the an input variable.

$inputs->page may not exist.

$variables->page = ($inputs->page ? $inputs->page : $variables->page);

I thought that this shorthand says:

"If $inputs->page exists then assign $variables-page to this variable, otherwise keep it as $variables->page ". But it seems that it's throwing the error because $inputs->page doesn't exist. What am I doing wrong?

Your shorthand says if $inputs->page is true then..

You have to change it using isset($inputs->page) or !is_null($inputs->page) or !empty($inputs->page) depending your case

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM