Is it possible to know the directory where the class instance was created? The path of the directory I need to know in the class to save the result in the same directory. So far I've only come up with a "bike" transmitting:
(new BasicTest('test_value', dirname(__FILE__))
in the class constructor itself. Are there other ways?
The instanceof operator in Java is used to check whether an object is an instance of a particular class or not. objectName instanceOf className; Here, if objectName is an instance of className , the operator returns true . Otherwise, it returns false .
The current working directory means the root folder of your current Java project. We can get the current working directory in Java using the following system property function: String cwd = System.
SomeClass::class will return the fully qualified name of SomeClass including the namespace. This feature was implemented in PHP 5.5. It's very useful for 2 reasons. You can use the use keyword to resolve your class and you don't need to write the full class name.
The current instance of an object is the instance in which the code is currently executing.
Yes, you can use debug_backtrace()
class A {
function __construct() {
var_dump(dirname(debug_backtrace()[0]['file']));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With