Is there a way to program 100% object-oriented in PHP?

前端 未结 2 1887
灰色年华
灰色年华 2021-01-23 08:02

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

But at the beginning, there is always an index.php or some

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 08:55

    You need an entry point into your application somewhere. Java's entry point happens to be a predefined named location which is automatically called when an app starts. PHP's entry point is the first line of the first file that executes. As such, you need to get the ball rolling with a single "procedural" call somewhere, which could simply be something like:

    require_once 'controller.php';
    new Controller;
    

    That's essentially the same thing Java does, just more explicitly.

提交回复
热议问题