[英]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. $inputs->page
可能不存在。
$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
". “如果
$inputs->page
存在,则将$variables-page
分配给此变量,否则将其保留为$variables->page
”。 But it seems that it's throwing the error because $inputs->page
doesn't exist. 但是似乎由于
$inputs->page
不存在而$inputs->page
错误。 What am I doing wrong? 我究竟做错了什么?
Your shorthand says if $inputs->page
is true
then.. 您的速记说明
$inputs->page
是否为true
。
You have to change it using isset($inputs->page)
or !is_null($inputs->page)
or !empty($inputs->page)
depending your case 您必须根据情况使用
isset($inputs->page)
或!is_null($inputs->page)
或!empty($inputs->page)
进行更改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.