Answer the question
In order to leave comments, you need to log in
How to use functions of another file in PHP?
There are 2 files. For example file.php and file1.php. There is a "getPages" function in file.php. How can I use this function in file1.php without using include and include_once?
I heard people do it through namespace... Or something like that.
Answer the question
In order to leave comments, you need to log in
require / require_once, you can get especially perverted by getting it through file_get_contents, tear out the function with regexp and declare it through eval, but why?
with functions in any way (at least until 5.6 which I use), and for classes you can make autoloading How to use namespace autoloading of php classes correctly?
If you don't have classes, then you can't do without include.
But even when your functions are class methods, and autoload is configured, then include is also done, only implicitly.
Therefore, it does not work at all without include.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question