Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend Exam 200-710 Topic 2 Question 55 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 55
Topic #: 2
[All 200-710 Questions]

What is the output of the following code?

var_dump(boolval(new StdClass()));

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Sabrina
2 months ago
I bet the correct answer is bool(false). StdClass is so standard, it's gotta be false, right?
upvoted 0 times
...
Barabara
2 months ago
Seriously, who writes code like this? It's like they're trying to trick us!
upvoted 0 times
Jennie
10 days ago
I would go with option A, it seems like a trick to make us think it's false.
upvoted 0 times
...
Deonna
15 days ago
B) bool(false)
upvoted 0 times
...
Kimberely
20 days ago
I know right, it's like a trick question.
upvoted 0 times
...
Rutha
25 days ago
A) bool(true)
upvoted 0 times
...
...
Kami
2 months ago
I'm going to go with bool(false) on this one. Can't fool me, PHP!
upvoted 0 times
Delfina
1 months ago
User 3: The output is bool(true)
upvoted 0 times
...
Gracia
1 months ago
User 2: I'm going with bool(false)
upvoted 0 times
...
Wynell
2 months ago
User 1: I think it's bool(true)
upvoted 0 times
...
...
Leanna
2 months ago
Wait, what? I thought boolval() would return false for an empty object. This is trickier than it looks.
upvoted 0 times
Erasmo
27 days ago
Yeah, I think it's true because the object is not empty.
upvoted 0 times
...
Kathryn
28 days ago
I'm not sure either, but I think it might be true because the object exists.
upvoted 0 times
...
Vashti
29 days ago
B) bool(false)
upvoted 0 times
...
Geoffrey
30 days ago
A) bool(true)
upvoted 0 times
...
...
Shakira
3 months ago
Easy peasy! It's got to be bool(true). Everything is truthy in PHP, even an empty object!
upvoted 0 times
Malinda
2 months ago
Exactly! PHP treats everything as truthy, even an empty object.
upvoted 0 times
...
Bulah
2 months ago
bool(true)
upvoted 0 times
...
Rodolfo
2 months ago
Exactly! PHP treats an empty object as true.
upvoted 0 times
...
Linwood
2 months ago
bool(true)
upvoted 0 times
...
...
Judy
3 months ago
A) bool(true)
upvoted 0 times
...
Chauncey
3 months ago
Hmm, I'm thinking it's going to be bool(false). After all, a new StdClass object is an empty object, right?
upvoted 0 times
Alfred
2 months ago
Yes, boolval() returns true for any non-empty object.
upvoted 0 times
...
Luis
3 months ago
Oh really? I thought it would be bool(false).
upvoted 0 times
...
Herminia
3 months ago
Actually, the output is bool(true).
upvoted 0 times
...
Johanna
3 months ago
A) bool(true)
upvoted 0 times
...
...
Domitila
3 months ago
B) bool(false)
upvoted 0 times
...
Mary
4 months ago
A) bool(true)
upvoted 0 times
...

Save Cancel