Finding the PHP File (at run time) where a Class was Defined
Try ReflectionClass
- ReflectionClass::getFileName — Gets a filename
Example:
class Foo {}
$reflector = new \ReflectionClass('Foo');
echo $reflector->getFileName();
This will return false
when the filename cannot be found, e.g. on native classes.
preloaded php class file location
Check the include path(s) to see which directories are relevant.
get_include_path
http://php.net/manual/de/function.get-include-path.php
Use Reflection class to get the actual file
http://de1.php.net/manual/de/reflectionclass.getfilename.php
Find out the directory where the class instance was created?
Yes, you can use debug_backtrace()
class A {
function __construct() {
var_dump(dirname(debug_backtrace()[0]['file']));
}
}
PHP: unable to locate functions being used (seemingly not defined)
Maybe the class was included in a php file that is including some external libraries? The functions might be taken from these libraries.
Get name of file which run function/class in PHP
See debug_backtrace.
In your MySql class you can simply call this function, and trace the call to it's origin.
PHP: Class file in the same directory not being recognized?
make sure you're actually declaring the class in your class file
class tattler_stats {
// class code here
}
if you are already doing that, try specifying the path more concretely:
include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.tattler_stats.php');
Related Topics
Strange Behaviour with Numbers That Have a Leading Zero
I Cannot Use MySQL_* Functions After Upgrading PHP
PHP Sessions with Disabled Cookies, Does It Work
Remove Diacritics from a String
How to Pull First 100 Characters of a String in PHP
Laravel Error: Missing Required Parameters for Route
Ini_Set("Memory_Limit") in PHP 5.3.3 Is Not Working at All
Can PHP and ASP.NET Run Together Within the Same Web Site in Iis 7.5
How to Pass an Array in Get in PHP
How to Display String That Contains HTML in Twig Template
Codeigniter - Why Use Xss_Clean
How Long Can a Tld Possibly Be
PHP Substr() Function with Utf-8 Leaves � Marks at the End
Why am I Getting Mime-Type of .CSV File as "Application/Octet-Stream"