Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

php - PHP中的stdClass是什么?(What is stdClass in PHP?)

请定义什么是stdClass

  ask by Keira Nighly translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

stdClass is just a generic 'empty' class that's used when casting other types to objects.

(stdClass只是将其他类型强制转换为对象时使用的通用“空”类。)

Despite what the other two answers say, stdClass is not the base class for objects in PHP.

(尽管有其他两个答案, stdClass 并不是 PHP中对象的基类。)

This can be demonstrated fairly easily:

(这可以很容易地证明:)

class Foo{}
$foo = new Foo();
echo ($foo instanceof stdClass)?'Y':'N';
// outputs 'N'

I don't believe there's a concept of a base object in PHP

(我不相信PHP中有基础对象的概念)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...