Does phpempty return true if it is an object without any attribute?

Source: Internet
Author: User
Tested: {code...} reply content:


See the PHP document: empty-check whether a variable is empty

Obviously, obj is not empty ~

Test:

Print_r ($ obj );

Game Object ()


Empty or non-empty are defined. don't guess ......


The object has been instantiated.EmptyIt is certainly not empty, I understandEmpty

Empty (''); // trueempty (0); // trueempty ('0'); // trueempty (NULL); // trueempty ([]); // trueempty (array (); // false $ a; // only defines empty ($ a) without assigning values ); // trueclass AA {}$ aa = new AA (); empty ($ aa); // false: the object actually exists. it is not empty. class BB {public $ name ;} $ bb = new BB (); empty ($ bb-> name); // true

This is obviously not empty. empty is generally used to judge Variables. In fact, it does not actually work to judge an object,
You create an empty object, which is different from assigning an empty variable or an empty array,
Or you can print it out and see, object (Game) [1]
This is printed,

The above is the php empty. will true be returned for objects without attributes? For more information, see The PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.