Autoload differnece between class and interface php?

You can use ReflectionClass::isInterface to determine if the class is an interface $reflection = new ReflectionClass($name); if ($reflection->isInterface()){ //Is an interface }else{ //Not an interface } In your case, you would probably have to use file_exist first on $name.interface. Php and $name.class. Php to determine if they exist, require the one that exists, then check if it's an interface However, my opinion is that this might cause problems down the track.

What if you have MyClass.class. Php and MyClass.interface. Php?

You can use ReflectionClass::isInterface to determine if the class is an interface. $reflection = new ReflectionClass($name); if ($reflection->isInterface()){ //Is an interface }else{ //Not an interface } In your case, you would probably have to use file_exist first on $name.interface. Php and $name.class.

Php to determine if they exist, require the one that exists, then check if it's an interface. However, my opinion is that this might cause problems down the track. What if you have MyClass.class.

Php and MyClass.interface. Php?

This requires an instance of the class.. – tandu Oct 28 at 3:43 @tandu, ReflectionClass' contructor does not necessary require an instance. You can pass in a string of the class name. – phpdev Oct 28 at 3:45 you're right, but you can only do that for classes that already exist.

– tandu Oct 28 at 3:47 Use reflection in autoload is a very bad idea. – xdazz Oct 28 at 3:52 @xdazz: Please elaborate :) – phpdev Oct 28 at 3:53.

You should have some naming conventions for your classes and interfaces e.g. Your class name is logon and interface name logon_interface, then you can easily differentiate between the two. For example, explode $name by underscore and check if last element is interface.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions