我注意到 Interspire Shopping Cart 将它的许多类初始化为 PHP 的 $GLOBALS 变量。执行此操作时是否存在任何性能或安全问题?
下面是一个假文件,但与 Interspire Shopping Cart 的写法相似。
<?php
// account.php
$GLOBALS['USER_ACCOUNT'] = new USER_ACCOUNT();
$GLOBALS['USER_ACCOUNT']->createPage(); //creating the page
?>
我注意到在创建页面的过程中(见上文),包含的其他文件将需要访问 $GLOBALS['USER_ACCOUNT']。因此,以后其他人将需要这个类实例。