我创建了一个带有构造函数(__construct())的类,但我不希望任何人能够访问它。我怎么能这么做?非常感谢!
编辑1:
关于更多细节:我创建了一个类:
<?php
class test{
function __construct()
{
$a=1;
}
}
$t = new test;
$t->//here's the problem
?>在我的编辑器中,当按$t->时,代码提示也显示('_construct()')和('$a')。我想问:其他人可以访问('$a')或('_construct()')吗?我怎么才能阻止,
发布于 2014-01-02 09:01:28
只需使构造函数private
class Test {
private function __construct() {}
}https://stackoverflow.com/questions/20879365
复制相似问题