Is there such a thing as using PHP include ()?

I use include to enable the various functions that I use, and now I am starting to use include to pull out pieces of HTML / PHP. Is there a point that I abused includes?

+3
source share
5 answers

Once you have trouble reading your own code that you wrote some time ago, this is definitely too much.

I recommend programming in object-oriented PHP and using autoloaders to avoid having to enable / require as much as possible. Excessive use of include / require often results in unreadable and irreplaceable spaghetti code, which is very bad.

In small projects, I usually have one request to perform the autoloader function, and in large applications I use the Zend Framework, where I rely solely on Zend_Loader.

From a purist point of view, I would say: more than 3 includes / requires too much in your own code (without third-party libraries):

  • One to incorporate some iniitialization material
  • One to load autoloader class / function
  • , . , / . .

.

+5

, , . -, , , , .

+1

, , , ( ). , , Drupal Wordpress, , include s.

HTML, . , MVC MVT. , ( ), 95% . , .

Frameworks ;)

Symphony CakePHP , , Smarty.

+1

, , , .

, , , , .

0

. , , script, , . Smarty, :

  • , .
  • PHP .
0

Source: https://habr.com/ru/post/1749008/


All Articles