Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在建立一个小网站作为一个项目,并且正在尝试 mvc。
我已经建立了一个请求类和一个路由器类。
很简单的问题,但是我已经阅读了所有关于全局变量由于某种原因而不好的地方,所以我应该将 $_GET、$_POST、$_SERVER 等传递到我的请求类中,或者只是从请求中引用它们班级。
new Request($_GET, $_POST, $_SERVER);
或者
new Request();
谢谢。
One of the main aspects of OOP is abstraction. So the class should not know about your Global Variables. What if you change the key of your GET. The first Method is the most common way.