有没有一种方法可以用PHP编程100%面向对象? [英] Is there a way to program 100% object-oriented in PHP?

查看:48
本文介绍了有没有一种方法可以用PHP编程100%面向对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,有可能在一个单独的类中调用函数,我在PHP中称为这种面向对象的编程.

I guess, it's possible to call functions in a separate class, I call this object-oriented programming in PHP.

但是在一开始,总会有一个index.php之类的东西,它会调用或实例化另一个类.

But at the beginning, there is always an index.php or something, which calls or instantiates another class.

是否有一种方法可以像Java

Is there a way at all to have a class which is self-calling in a way like java does with

public static void main(String[] args) ...

推荐答案

默认情况下不.但是您可以编写自己的 bootstrap 来做到这一点,

Not by default. But you could write your own bootstrap that does this, see a related answer that outlines how you can do it.

如果index.php是您唯一的中央入口点,则它已经是引导程序.

If index.php is your only central entry point, it's already the bootstrap.

从那时起,您可以完成所有您喜欢的OOP.但是,我认为您的问题不是关于OOP,而是关于如何处理应用程序代码的调用.

From that point on, you can do everything OOP you like. However, I think your question is less about OOP but more about how you deal with the invokation of your application code.

这篇关于有没有一种方法可以用PHP编程100%面向对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆