Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么 php empty() 没有值 #7

Closed
FupingQiu opened this issue Aug 10, 2018 · 2 comments
Closed

为什么 php empty() 没有值 #7

FupingQiu opened this issue Aug 10, 2018 · 2 comments

Comments

@FupingQiu
Copy link
Owner

FupingQiu commented Aug 10, 2018

    $annualObject = $this->repository->findWhere([
		'id' => $id
	]); 当$annualObject为空的时候。
   empty($annualObject)的值,不是true / false 而是空?

var_dump(empty($annualObject))输出值为: bool(false)

isset($annualObject) 为 1, 已经被定义。
gettype($annualObject) 为 Object。

@FupingQiu
Copy link
Owner Author

FupingQiu commented Aug 10, 2018

空对象在 PHP 5 以上版本中计算结果不为 false:
集合对象可以判断count($order->orderDetail) > 0,或者 $order->orderDetail->isEmpty()
https://laravel-china.org/docs/laravel/5.3/collections/1206#method-isempty

@FupingQiu
Copy link
Owner Author

空对象在 PHP 5 以上版本中计算结果不为 false:
集合对象可以判断count($order->orderDetail) > 0,或者 $order->orderDetail->isEmpty()
https://laravel-china.org/docs/laravel/5.3/collections/1206#method-isempty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant