如果我的类都在common.php中,我可以单独定义我的类吗?


Can I define my classes separately if my classes are all in common.php

我想做以下事情:

<?php
session_start();
require_once "../includes/common.php";
$quoteShared = new quoteShared();
?>

common.php有:

<?php
require_once "../objects/quote/shared.php";
... plus many others
?>

这给了我错误:

致命错误:类' quotesshared ' not found

我想在包含它们的地方单独定义类,这样我就可以在不同的页面上使用我需要的特定类。这能做到吗?

这是一个糟糕的设计策略,你应该看看这里:http://php.net/manual/en/language.oop5.autoload.php

相关文章: