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

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

Jun 13, 2016 pm 01:38 PM
function main

希望指点错在哪里,应该要怎么样改?
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 在哪里赋值的?

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does computer main mean? What does computer main mean? Jan 19, 2021 pm 02:57 PM

Computer main represents the main menu or main category in computer software. Some desktop software will have a main menu, including basic operation menus, named main; and in high-level languages ​​such as development languages ​​​​java and c language, there will be a main class, which is the entrance to program execution. A program can have multiple functions, but there can only be one main() function.

What does function mean? What does function mean? Aug 04, 2023 am 10:33 AM

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

Does the linux kernel have a main function? Does the linux kernel have a main function? Mar 28, 2023 am 10:45 AM

The Linux kernel has a main function; the main function is the entry point of the program, and main is an interface name agreed between the application and the operating system, so the first function of each application in Linux must be main.

What interface is MAIN? What interface is MAIN? Mar 06, 2023 am 11:50 AM

MAIN is the main antenna interface, and aux is the auxiliary antenna interface; most Intel wireless network card motherboards only have numbers 1, 2, and 3. The main number identified is 1 (connected to the gray line), and the aux number is 2 (connected to the black line). If there are 3, usually connect the white line.

What is the purpose of the 'enumerate()' function in Python? What is the purpose of the 'enumerate()' function in Python? Sep 01, 2023 am 11:29 AM

In this article, we will learn about enumerate() function and the purpose of “enumerate()” function in Python. What is the enumerate() function? Python's enumerate() function accepts a data collection as a parameter and returns an enumeration object. Enumeration objects are returned as key-value pairs. The key is the index corresponding to each item, and the value is the items. Syntax enumerate(iterable,start) Parameters iterable - The passed in data collection can be returned as an enumeration object, called iterablestart - As the name suggests, the starting index of the enumeration object is defined by start. if we ignore

Detailed explanation of the role and function of the MySQL.proc table Detailed explanation of the role and function of the MySQL.proc table Mar 16, 2024 am 09:03 AM

Detailed explanation of the role and function of the MySQL.proc table. MySQL is a popular relational database management system. When developers use MySQL, they often involve the creation and management of stored procedures (StoredProcedure). The MySQL.proc table is a very important system table. It stores information related to all stored procedures in the database, including the name, definition, parameters, etc. of the stored procedures. In this article, we will explain in detail the role and functionality of the MySQL.proc table

What is the use of main function in Java What is the use of main function in Java May 04, 2023 am 09:34 AM

The general way of writing the main function is as follows: publicstaticvoidmain(String[]args){…} The functions of these keywords are explained below: (1) public keyword, this is easy to understand. Declaring the main function as public tells other classes that they can access this function. (2) The static keyword tells the compiler that the main function is a static function. That is to say, the code in the main function is stored in the static storage area, that is, this code already exists after the class is defined. If the main() method does not use the static modifier, then there will be no error in compilation, but if you try to execute the program, an error will be reported, prompting

What is the reason why Python does not have a main function? What is the reason why Python does not have a main function? Apr 19, 2023 am 10:01 AM

Why must main function be forced as the entry point? These languages ​​are compiled languages, which require the code to be compiled into executable binaries. In order for the operating system/bootloader to find the beginning of the program, such a function needs to be defined. In short, you need to define a crucial beginning in a large amount of executable code. It is not difficult to see that for these languages, the main function is an indispensable component. However, when we turn our attention to Python, we will find that the situation is very different. Python is an interpreted language, a scripting language. The running process is performed from top to bottom, line by line, which means that its starting point is known. Each .py file is an executable file and can be used as the entry file for the entire program, meaning

See all articles