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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:48:49+00:00 2026-06-19T04:48:49+00:00

I am working on replacing some old objects with updated ones in php. The

  • 0

I am working on replacing some old objects with updated ones in php. The site currently has an __autoload function that simply calls a .inc file in the include directory. I have created a new autoload function for the updated objects using spl_autoload_register. It uses a directory named lib and namespaces.

I have an object named Sample, and the old object, also named Sample, references a definition in include/sample.inc. Then new object path is lib/Sample.php. My problem is, even though I am using the spl_autoload_register on the page that is calling the object, it is still calling the old object. Here is my code (please note that the __autoload() is defined prior to reaching this page).

<?php
spl_autoload_register('autoload_lib');
$sample_id = req('sample_id');
$alert = req('alert');

if (!empty($sample_id))
{
    $sample = new Sample($sample_id);
    var_dump($sample); die();
    $referral = $sample->Referral();

    matry::open (get_defined_vars());
}
else
        {
            matry::open(get_defined_vars());
        }
  • 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-19T04:48:50+00:00Added an answer on June 19, 2026 at 4:48 am

    When you start using spl_… methods, they usurp any existing __autoload function:

    If your code has an existing __autoload() function then this function
    must be explicitly registered on the __autoload stack. This is because
    spl_autoload_register() will effectively replace the engine cache for
    the __autoload() function by either spl_autoload() or
    spl_autoload_call().

    One can see this in a simple example:

    <?php
    
    ini_set('display_errors', 1);
    
    function __autoload($className) {
        exit("__autoload");
    }
    
    spl_autoload_register(function($className) {
        exit("spl_autoload");
    });
    
    // try to create nonexistent class
    new Foo();
    
    ?>
    

    The above example outputs “spl_autoload”

    Are you sure no other autoloader has been registered at that stage in the script? You could test this by adding the prepend argument (e.g., spl_autoload_register(‘autoload_lib’, true, true); Is autoload_lib callable at that time in the script (has it’s source been included?)

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

Sidebar

Related Questions

I'm currently working on an app using MVVM that needs to have some data
I am doing some URL redirections in a project that I am currently working
I'm currently working on some code and, up to now, everything has compiled fine.
I'm working on an old site and i would avoid searching&replacing and i was
Here is a little background information. I'm working on replacing a dll that has
Working with an undisclosed API, I found a function that can set the number
I am currently working on a very large legacy MFC MDI application. It has
I'm working on some code that is normalizing a lot of data. At the
I'm having some troubles with the PHP function str_replace when using arrays. I have
I'm trying to create a chaining function for working with strings that are returned

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.