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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:06:12+00:00 2026-05-26T02:06:12+00:00

When I read the source of Codeigniter, I found a function located in file:system/codeigniter/comm.php

  • 0

When I read the source of Codeigniter, I found a function located in file:system/codeigniter/comm.php like that:

/**
* Instantiate Class
*
* Returns a new class object by reference, used by load_class() and the DB class.
* Required to retain PHP 4 compatibility and also not make PHP 5.3 cry.
*
* Use: $obj =& instantiate_class(new Foo());
*/
function &instantiate_class(&$class_object)
{
    return $class_object;
}

I can’t undestand it well, and I need more details about the compatibility things. Thanks.

update: Codeigniter version is 1.7.2

  • 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-26T02:06:13+00:00Added an answer on May 26, 2026 at 2:06 am

    The function and it’s example use in question is totally bogus:

    $obj =& instantiate_class(new Foo());
    

    That’s the same as writing:

    $obj =& new Foo();
    

    Which is the way that needed to be done in PHP 4.

    Since PHP 5, you can just write:

    $obj = new Foo();
    

    as you might know.

    Actually, as you, I do not see any use of the function just for the sole purpose that it’s superflous. It might have had some need in the past (when it had some other definition). I can only assume about it’s existance, most likely that the developer had problems to understand references/aliasing in PHP which is commonly not well understood.

    Edit: As KingCrunch pointed out, there is a need for this function if you would like to glue PHP 4 with PHP 5.3 code, because it will prevent strict standards warnings in PHP 5.3. So instead of the PHP 4 (potentially needed)

    $obj =& new Foo();
    

    This must be written as

    $obj =& instantiate_class(new Foo());
    

    Which hides away the “Assigning the return value of new by reference is deprecated” warning and allows to code in a PHP 4 style for a PHP 5.3 environment.

    Hope this helps you with your software archaeology.

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

Sidebar

Related Questions

Hi is there any tool available in Java world that will parse/read a source
I would like to be able to read the html source of a certain
I read from source.sql ( sql script ) file INSERT INTO `Tbl_abc` VALUES (1111,
is there anyone have read the source code of dtl in c++? I found
I'm looking for an option to gcc that will make it read a source
We have an existing application that makes use of the System.IO.Packaging.Package class for reading
I try to read Claroline source code to learn from their coding. In index.php
I'd like to read the source code of one of the popular revision control
When I read source from open source projects I often find a comment line
I read some source code of ZenTest but didn't find where it is implemented.

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.