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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:59:54+00:00 2026-06-03T00:59:54+00:00

Possible Duplicate: php: determine where function was called from I have an autoloading function

  • 0

Possible Duplicate:
php: determine where function was called from

I have an autoloading function my_function($class) that could be called by any script. It is called by PHP’s spl_autoload_call() and that can happen everywhere. How do I script my_function($class) to detect when it is called by a specific $file?

Something like:

$file = '/htdocs/project/whatever.php';
if ($caller_file == $file) {
    ...

How do I find $caller_file?
I do understand this question is confusing but I can’t put it in better words right now. So if you have any problem understanding just let me know in the comments.

Edit (Context) I want to make the script load a different class’s file if the file the autoloader would load is the same in which the autoloader is called.

For example giving:

namespace Something;
class Random extends Random {}

should not load itself, but a different file in which we have:

namespace Something;
class Random { ... }

In other words:

What if I’m defining MyName\Class in a/class.php and I want to extends itself with MyName\Class extends \MyName\Class (inside a/class.php) but I want the autoloader to look \MyName\Class in b/class.php when it is asked within a/class.php?

  • 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-03T00:59:56+00:00Added an answer on June 3, 2026 at 12:59 am

    Have you tried debug_backtrace() ?

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

Sidebar

Related Questions

Possible Duplicate: Caller function in PHP 5? php: determine where function was called from
Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: PHP pagination class are there any PHP/Class libraries that i can utilize
Possible Duplicate: PHP - send file to user I have written a script that
Possible Duplicate: PHP: Script for generating Crossword game? Does anyone know any PHP-based simple
Possible Duplicate: Php function to determine if a string consist of only alphanumerical characters?
Possible Duplicate: PHP last day of the month Is there any function like $date->getMonthDays()
Possible Duplicate: PHP: Require() and Class Hierarchies Is this bad practice? Is there any
Possible Duplicate: php mail() function on localhost I am using php mail(). I have
Possible Duplicate: php in background exec() function After a certain script runs on website

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.