How can i use this extends class without requiring it at the top?

Two_One class is in the Second Folder … :frowning:

You can’t. extends HAS to be called immediately right after the class call if you want to extend a parent class. If you try doing it at the end of the file or at random places within the file, you’ll get an error. You should also require that file before this file is included.

You can autoload your classes if you don’t want to include them at the beginning of each file.

1 Like

Best practice is to use composer and auto-load classes using PSR-4 naming conventions.

Given those tools cluttering an application with requires and includes is very poor practice.

Guys thanks for answering my question :slight_smile: I already fixed this kind of problem by using psr-4 in composer :smiley: … thanks for all your reply and suggestions

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.