Reply to a phper face question answer

Source: Internet
Author: User



1. What is the pros and cons of references, and questions about function return references.

2. There is a PHP problem is let me complete a class interface, I do not understand what is the interface, I hope the master pointing.

3. Encountered some questions about the class, public static use of what, I hope you give a relevant tutorial to see.

4. The following section of code
<?php
Note that the!== operator does not exist before 4.0.0-RC2

if ($handle = Opendir ('/path/to/files ')) {
echo "Directory handle: $handlen";
echo "Files:n";

/* This is the right way to traverse the directory method * *
while (false!== ($file = Readdir ($handle))) {
echo "$filen";
}

Closedir ($handle);
}
?>


Why false!== here with!== instead of!=?


5. What is the point of the last class file that I finished today?



My reply is as follows:

As a senior interviewer, the answers are as follows:
1. Usually in large programs, a deep understanding of the reference and handling of the relevant code affect the efficiency of the implementation of the problem, improper processing of the reference will make the program less than 35% more efficient, such as the associated program too much, will be slower. So what is a reference? To understand the reference first you have to understand what is a variable? $name = "Jiania" , the $name here is the variable, and if $username=& $name, then we say that the variable $username to the same object as the variable $name, that is, Jiania, which means they point to the same place. In function or OO, And something to be aware of.
Example:
Environment: php5.1.6 up
$powman =new Jiania ();
Note that the new Jiania () is not preceded by and, if added, an error occurs because, in the high version, the reference here is given to the Zend engine for processing, which restricts this.

B. If you assign a reference to a variable declared as global within a function, the reference is visible only inside the function. You can avoid this by using a $GLOBALS array.
C. The best copy of a complex array rather than a reference.
D. $this, in the method of an object, $this is always a reference to the object that called it.
2. In fact, the landlord interview does not know what level of programmers, PHP related interface in reality very few programmers really use. Now, of course, the person playing the frame is the exception. I am a Java programmer, starting with the 05 PHP framework and having some understanding of the interface. Now explain.
If you want to understand the interface, first you have to understand what is called the object, then what is the object? Everything is object, all things as objects, such as my name is called 洪建 home, my child's name is small house, here is the name of the object, 洪建 home and small family are people, this is the class, OK, understand what is the class and object, and then I tell you what is the pump like class, in reality we often describe some objects, But there is no specific implementation method, such classes are abstract classes, such as
Abstract class callme{
Abstract function showMe ();

}
Class Callson extends CallMe {
function showme{
Print "Callson::showme () n";
}
}
The CallMe here is the extraction class, which can only be implemented by subclasses. OK, understand what is called the drawing class, we will explain what is the interface below.
For starters, you can understand that interface (interface) is a variant of an abstract class. Some people who have just contacted Oo will ask why it is necessary to distinguish between what is an interface and what is a pumping class, and the interface is used to implement multiple inheritance. The following is a simple demo of an interface that requires the Implements keyword to implement any interface

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.