T
T
Turar Abu2016-04-09 22:26:30
PHP
Turar Abu, 2016-04-09 22:26:30

How to declare a class function outside the class or inside __construct()?

Such task interests:
There is a certain class which will be modified each time. And to make it easy to do, I decided to separate the class functions into different folders.

config (главная папка)
-- link (папка функции для работы с link)
-- title (папка функции для работы с title)

etc.
With the help of a cycle that is in __construct()or outside the class itself, I load each file. But I don't know how to declare a function for this class to make this code work:
Class config {
   function __construct(){
      // здесь подгружаются файлы
   }
}
// или подгружать здесь
$config = new config();
$config->getLink('protocol');

How can this be implemented? If there are alternatives, I'm glad to know. The main thing is that all functions from different files work using one variable, like$config;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-04-09
@kemply

there is no such crutch that a pkheshnik cannot come up with.
- create a base abstract class, from which you inherit further
- https://ru.wikipedia.org/wiki/Decorator_(template_pr...
- runkit
- answer D' Normalization
but all this in this case did not fucking fall: it's more convenient to edit the class ( with autocomplete and other goodies), and not 100,500 separate functions, spread evenly on the disk.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question