简体   繁体   English

ErrorException试图获取非对象的属性

[英]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.

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