Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include methods from external php file in a class

Tags:

oop

php

I have a class with own methods and on the other side a php file what contains external methods. From documentation is clear that inside of a class includeing external functions is not possible

How could I inculde this functions in my class. Making an another class and extend my first class it can not be an option.

like image 583
kakuki Avatar asked Dec 20 '22 13:12

kakuki


1 Answers

You can't. All class definition, including methods and fields must be on the same file. You can't declare the same class in two different files.

Extending, or using traits (if you have PHP 5.4.x+), are your only options.

like image 193
Madara's Ghost Avatar answered Jan 07 '23 16:01

Madara's Ghost