Home > Backend Development > PHP Tutorial > 希望指点错在哪里,应该要如何样改

希望指点错在哪里,应该要如何样改

WBOY
Release: 2016-06-13 13:38:19
Original
1056 people have browsed it

希望指点错在哪里,应该要怎么样改?
interface PCI{
function ShowDiveceName();
}
class SoundAdaper implements PCI{
function ShowDiveceName(){
echo "SoundAdaper
";
}
}
class NetworkAdaper implements PCI{
function ShowDiveceName(){
echo"NetworkAdaper
";
}
}
class DisplayAdaper implements PCI{
function ShowDiveceName(){
echo"DisplayAdaper
";
}
}
class Mainboard{
private $PciDevice;
function plug($PciDevice){
$this->PciDevice=$PciDevice;
}
function PCI(){
$this->PciDevice->ShowDeviceName();
}
}
class Engineer{
function Work($Main,$PciDevice){
$Main->plug($PciDevice);
//Fatal error: Call to a member function plug() on a non-object in C:\wamp\www\class_class.php on line 39
//不太明白$Main->plug($PciDevice);这错在哪里
}
}

$sound = new SoundAdaper();
$video = new DisplayAdaper();
$net = new NetworkAdaper();
$main = new MainBoard();
$people = new Engineer();
$people->Work($Main,$SoundAdaper);
$main->PCI();
$people->Work($Main,$DisplayAdaper);
$main->PCI();
$people->Work($Main,$NetworkAdaper);
$main->PCI();
?>

------解决方案--------------------
另外 $SoundAdaper、$DisplayAdaper、$NetworkAdaper 在哪里赋值的?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template