我有下一个类和接口
namespace includ\views;
interface IView
{
public function getContenido( );
public function imprimirContenido( );
}
namespace includ\views;
require_once ('IView.php' );
use includ\views\IView as IView;
interface IMenu extends IView
{
public function getTipo();
public function __clone();
}
namespace includ\views;
require ('IMenu.php');
use includ\views\IMenu;
class MenuAdministrador implements IMenu
{
...
}
并制作一个数组
require_once ( 'menu/MenuAdministrador.php' );
$menus=array();
$menus[] = new includ\views\MenuAdministrador();
//or other way
//array_push( $menus, new includ\views\MenuAdministrador() );
但是,我尝试检查课程的类型,我做了一些类似的事情:
var_dump($menus[0] instanceof IMenu );
答案是:
bool(false)
将对象(类)添加到数组的最佳方法是什么?