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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:20:24+00:00 2026-06-15T13:20:24+00:00

Take the following code from CodeIgniter’s show_error function: $_error =& load_class(‘Exceptions’, ‘core’); The documentation

  • 0

Take the following code from CodeIgniter’s show_error function:

$_error =& load_class('Exceptions', 'core');

The documentation for the load_class function says it acts as a singleton. The function basically takes the given parameters and searches for a class in the appropriate path. It then includes the file if it exists. The function is declared as:

function &load_class(...)

Why does it have the & and what is its purpose? Is $_error declared as such as a result of defining the function like that?

  • 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-15T13:20:25+00:00Added an answer on June 15, 2026 at 1:20 pm

    The php documentation seems to explain why you have to uses =& even though the function is marked to return a refrence function &load_class

    Returning References

    Returning by reference is useful when you want to use a function to
    find to which variable a reference should be bound. Do not use
    return-by-reference to increase performance. The engine will
    automatically optimize this on its own. Only return references when
    you have a valid technical reason to do so. To return references, use
    this syntax:

     <?php class foo {
         public $value = 42;
    
         public function &getValue() {
             return $this->value;
         } 
      }
    
    
    
    $obj = new foo; 
    $myValue = &$obj->getValue(); // $myValue is a reference to $obj->value, which is 42.
    $obj->value = 2; 
    echo $myValue;
    // prints the new value of $obj->value, i.e. 2. ?> 
    

    In this example,

    the property of the object returned by the getValue function would be
    set, not the copy, as it would be without using reference syntax.
    Note: Unlike parameter passing, here you have to use & in both places
    – to indicate that you want to return by reference, not a copy, and to indicate that reference binding, rather than usual assignment, should
    be done for $myValue.

    If you are asking what references in general are the documentation explains.

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

Sidebar

Related Questions

Take the following demo code (from the GIO answer to this question), which uses
Take the following code example: File package1/__init__.py : from moduleB import foo print moduleB.__name__
Take the following code: $(#docUploadForm).on(submit, function(event) { event.preventDefault(); }); Simple enough so far, right?
Take the following rather standard code: from optparse import OptionParser opts = OptionParser() opts.add_option('-f',
Would someone please take a look at the following code fragments (all from one
Take this following code from an example HR system. The user has the ability
Take the following code: private var m_iQuanitity:int; public function get quantity():int { return m_iQuantity;
Take for example following code from a class: public class Employee : IEntity {
Take the following code snippet: SPAttachmentCollection attachments = item.Attachments ; What exactly is SPAttachmentCollection
Take the following code: <abbr title=World Health Organization>WHO</abbr> Can we style an abbr tag's

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.