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 9148493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:17:18+00:00 2026-06-17T11:17:18+00:00

Or, does my variable hold the object itself? When I say for example: $obj

  • 0

Or, does my variable hold the object itself?

When I say for example:

$obj = new ClassOne();

is the $obj a pointer to the object created in the memory? Does it hold only the memory address to the object? Or does it hold the object itself?

For example when I say,

$obj = new SomeOtherClass();

Will ClassOne object be garbage collected like in JAVA, or will it cause a memory-leak like in C++?

  • 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-17T11:17:21+00:00Added an answer on June 17, 2026 at 11:17 am

    Briefly, the object models in C++ and Java are a bit different:

    • C++ has unconstrained variables: Every object type can occur as the type of an object that is a vari­able. In other words, variables can be objects of any type. (But not all va­ri­ables are objects (e.g. re­fe­rences)!) Moreover, all variables are scoped, and thus the lifetime of all objects-that-are-variables is also scoped automatically. Only dynamically-allocated objects can never be variables, and they can only be handled via pointers and references.

    • In Java, if we ignore the primitive types, variables are never objects, and objects can never be variables. All objects are always "magically somewhere else" (e.g. "the GC heap"), and you can only ever handle them through pointer-like handles. In Java, a variable of type T is always a reference to the actual object of type T, which lives somewhere else. Variables are also scoped, like in C++, but the lifetime of all Java objects is indeterminate, and only guaranteed to ex­tend beyond the lifetime of all references to a given object.

      (The situation is different for built-in, "value"-type types like int, which can occur as the type of variables, and in fact cannot be allocated dynamically.)

    • I think PHP is similar to Java in that regard.

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

Sidebar

Related Questions

Does anyone know how to watch a variable in calling function. For example: C#:
What is the assembly language variable bl? How many bits does it hold? Is
Let's say variable A and B hold instances of managed objects in the same
I created a variable to hold a relative path because I cannot have a
does something need to hold a reference to a singleton objective-c object in order
If i declared a variable as public in a web page, does this variable
I have an array and variable. If the variable does not exist in the
Does T-SQL allow a variable number of arguments to a stored procedure like params
Does anyone know what a variable highlighted in red means? Thanks.
Does an assignment of a real to a variable starting with I convert to

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.