Adding functions to PHP core

前端 未结 5 806
礼貌的吻别
礼貌的吻别 2021-01-22 17:56

I have several functions that I wrote and I use regularly on my servers, is there a way I can add them to the core so I don\'t have to include them from external files?

5条回答
  •  天命终不由人
    2021-01-22 18:38

    I've done this before.. it's a fairly involved process, but not too bad. This article at zend.com should tell you everything you need to know:

    http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/

    edit: I should add that there are better ways to achieve the essence of what you're trying to do. Remember that doing this will further clutter up PHP's (already very cluttered) namespace. You're probably better off just making a global include file that has all of your most commonly used functions that you include wherever you need it.

    edit2: Upon rereading your original question, you said you don't want to do that, but I still think it's probably the best way. But best of luck to you with the extension route.

提交回复
热议问题