autoload functions in php

后端 未结 5 831
难免孤独
难免孤独 2020-12-07 03:35

Is it possible to autoload functions?

What I have is I have written functions distributed over different files named after the function name, so what I need is to au

5条回答
  •  时光说笑
    2020-12-07 04:02

    Although this is not wise, it is possible.

    You may save those functions in a file and prepend this file to all requested scripts:

    • front controller pattern (one central file for all requests, include it there)
    • php's auto_prepend_file

    But the wise, OOP solution would be to group those functions into classes and use __autoload or some framework autoloader like Zend_Autloader to speed things up and load just the features you need.

提交回复
热议问题