In beginner's learning, I want to understand this post. at last, the post was edited by xuzuning from 2012-11-1922: 06: 50 & lt ;? Phpinterface & nbsp; PCI {function & nbsp; start (); function & nbsp; stop () ;}class & nbsp; N beginner class learning, understanding
This post was last edited by xuzuning at 22:06:50, January 19 ,.
Interface PCI
{
Function start ();
Function stop ();
}
Class NetCard implements PCI
{
Function start ()
{
Echo "network connection successful
";
}
Function stop ()
{
Echo "network disconnected
";
}
}
Class SoundCard implements PCI
{
Function start ()
{
Echo "sound available
";
}
Function stop ()
{
Echo "no sound card device is available
";
}
}
Class ViewCard implements PCI
{
Function start ()
{
Echo "show image
";
}
Function stop ()
{
Echo "no available video card device
";
}
}
Class MainBoard
{
Function usePCI ($ pci)
{
$ Pci-> start ();
$ Pci-> stop ();
}
}
Class Person
{
Function install ()
{
$ Mb = new MainBoard ();
}
}
$ P = new Person ();
$ P-> install ();
$ Nc = new NetCard;
$ Mb-> usePCI ($ nc );
// The Program reports such an error and does not understand it,
Fatal error: Call to a member function start () on a non-object in C: \ wamp \ www \ PCI. php on line 63
------ Solution --------------------
Class Person
{
Function install ()
{
$ Mb = new MainBoard ();
}
}
Do you mean this?
$ Mb is created in the install method. if the method is complete, no more
It does not change the scope of a variable because it is a class.