Just for the case the autoload thing won't work, I wonder if it's fine with PHP to include a class inside a method?
Example:
public method doSomething() {
include ('MyClass.php');
$foo = MyClass::doAnotherThing();
}
main method in inner classes Inside inner class we can't declare static members. So that it is not possible to declare main() method inside non static inner class.
In Java, we can create Objects in various ways: Using a new keyword. Using the newInstance () method of the Class class. Using the newInstance() method of the Constructor class.
A nested class can be declared as a private, public, protected, internal, protected internal, or private protected. Outer class is not allowed to access inner class members directly as shown in above example. You are allowed to create objects of inner class in outer class.
Yes, you can definitely do that. In fact, that's exactly what the auto-loading does anyway, since __autoload()
is itself a function, and you generally use it to look around for your class file to load.
If you manually include your class files like that however, you'll definitely want to use require_once()
rather than include()
or require()
, otherwise you'll get a duplicate declaration of the class.
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