Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:36:47+00:00 2026-06-15T00:36:47+00:00

I was given a question to answer without executing. class Foo { public $x;

  • 0

I was given a question to answer without executing.

class Foo {
    public $x;
}
$a = new Foo();
$b = new Foo();
$a->x = $b;
$b->x = $a;

print_r($a == $b);

I thought this should print 1 but when i executed it gave a fatal error.

Fatal error: Nesting level too deep - recursive dependency? on line 13

Can anyone explain why i am getting this error ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:36:49+00:00Added an answer on June 15, 2026 at 12:36 am

    Because of the way PHP compares objects.

    When you compare objects with ==, PHP will look at each property of each object (and nested objects, in case some properties contain other objects), and compare them. The objects would be considered equal if all properties are equal.

    In this specific case, you’re placing the objects within each others’ properties, causing the comparison engine to loop ($a->b->a->b->a->b->...), which throws an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Updated question given Andrew Hare's correct answer: Given the following C# classes: public class
This post asks this question but doesn't really give an answer, so I thought
Referring to this question, no solution/answer was given for Oracle platform. Selecting Nth Record
N.B This question has been significantly edited before the first answer was given. Hi,
Given this output to one query: ID | Question | Answer 1 | 1
I have touched on this question in others before but after writing an answer
OK, I know this question seems pretty easy to answer, or maybe documented, but
Question 1: Given <input type=radio name=foo value=1 /> <input type=radio name=foo value=2 /> <input
Another question on StackOverflow is asking how this is done, but the general question
Given a string like this: <a href=http://blah.com/foo/blah>This is the foo link</a> ... and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.