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

  • SEARCH
  • Home
  • 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 6040043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:27:26+00:00 2026-05-23T06:27:26+00:00

I am really confused with this one. Here’s my code class inner { var

  • 0

I am really confused with this one. Here’s my code

class inner
{
    var $val = 0;   
}

class outer
{
    var $obj=null;

    function outer()
    {
        $this->obj = new inner;
    } 

    function get_obj()
    {
        return $this->obj;
    }
}


$app = new outer;

$obj = &$app->get_obj(); //get object by reference (& is not necessary in PHP5)
$obj->val = 1; //change something
echo $app->obj->val; //check whether it affected the original object source
//here it should display 1

When I am testing this on my local server, which is PHP 5.2.10-2ubuntu6.4, everything works fine and it displays 1. When I am testing this on my customer’s PHP Version 5.2.9 server, it displays 0. Is there some known PHP bug or may be some php.ini setting that could affect this behavior?

  • 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-05-23T06:27:26+00:00Added an answer on May 23, 2026 at 6:27 am

    If not works, try replace this

    function get_obj()
    

    By this

    function &get_obj()
    

    Usefull links:
    http://php.net/manual/en/language.references.pass.php
    http://php.net/manual/en/language.oop5.references.php

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

Sidebar

Related Questions

Really confused with this one. I am selecting an 'a' element by its class
I'm really confused on this one. I'm trying to do a simple ajax request,
I am bringing out a separate question from here . It really confused me.
Pardon me for giving you a confusing title on this problem. I'm really confused
I am really confused as to why sometimes vars will not work when var
I am using Entity Framwwork and Code First and getting really confused. I have
I am reading WIX script written by others. There are some code really confuses
Really stuck on trying to write code to unzip a file or directory on
I really enjoyed Jeff's post on Spartan Programming . I agree that code like
I am really confused now on how and which method to use to return

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.