Sort out some of the PHP interview topics

Source: Internet
Author: User
Tags sorts

What are the roles of 1.strlen () and Mb_strlen () respectively?

The role of strlen () and Mb_strlen () is to get the length of the string, where strlen () is only for single-byte encoded characters, that is, the total number of bytes of the string, and if it is multibyte-encoded, such as GBK and UTF8, use strlen () Instead of the total number of characters, you can use Mb_strlen to get the number of characters, and use mb_string to notice two points, one to open the mbstring extension, but to specify a character set.

Apply the following example

2.include and require can have a file included in the current file, what is the difference between the two? What is the difference between include and include_once?

The include function reads the specified file into and executes the program inside;

The Require function reads the contents of the target file and replaces itself with these read-in content;

Include and require in addition to handling the introduction of files in different ways, the biggest difference is that the include in the introduction of the file does not have a warning and the script will continue to execute, and require will cause a fatal error and the script to stop execution. Include and require in addition to handling the introduction of files in different ways, the biggest difference is that the include in the introduction of the file does not have a warning and the script will continue to execute, and require will cause a fatal error and the script to stop execution.

The include_once (require_once) statement contains and runs the specified file during script execution. This behavior is similar to the include (require) statement, except that if the code in the file is already contained, it will not be included again and will only be included once. Include_once (require_once) needs to query the list of files that have been loaded, confirm that it exists, and then load it again. The Include_once statement contains and runs the specified file during script execution. This behavior is similar to the include statement, except that if the file is already contained, it will not be included again. As the name of this statement implies, it is included only once;

What is the difference between 3.POST and get?

1. Get is the data that is fetched from the server and post is the data sent to the server.
2. Get is received by sending HTTP protocol via URL parameter passing, while post is entity data, submitted by Form
3. Get transmits a small amount of data, cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, the maximum amount of IIS4 is 100KB in 80KB,IIS5.
4. Get security is very low, post security is high.

What is the difference between 4.foo () and @foo ()?

Foo () executes this function, any interpretation errors, syntax errors, and execution errors will be displayed on the page.

@foo () hides the above error message when executing this function.

Many applications use @mysql_connect () and @mysql_query to hide MySQL error messages, so bad, errors should not be hidden and should be handled properly.

Information about the current script, $_server, in 5.PHP.

Client ip:$_server["REMOTE_ADDR"]

Server-side ip:$_server["SERVER_ADDR"]

Gets the execution path of the current script: $_server["Script_filename"] or __file__

Name of current script: $_server["php_self"] or $_server["Seript_name"]

URL to link to previous page address: $_server["Http_referer"]

6.sort (), Asort (), Ksort (), Arsort (), Rsort () What are the differences.

Sort () sorts the array cells to be rescheduled from lowest to highest when the function ends.

Rsort () Reverses the order of the arrays.

Asort () sorts the array and maintains the index relationship.

Arsort () Reverses the array and maintains the index relationship.

Ksort () Arrays are sorted by key name, preserving the association of key names to data, primarily for associative arrays.

7. What are mutable variables? What are the input values for the following programs?

Gets the value of an ordinary variable as the variable name of the variable variable.

Above program output: Hotdogok

8. How constants are defined, and how do you detect if a constant is defined?

Defining constants: Define ()

Detection constants are defined: defined (), for example

Define ("TEST", "Hello World");

if (Defined ("TEST")) {

Echo TEST;

}

9. <?php Echo 8% ( -2) of the Execution procedure section, the output is:

% is the modulo operation, the above program will output 0

$a% $b, the positive or negative of the result depends on the sign of $ A.

Echo ((-8)%3); Will output-2

Echo (8% (-3)); Will output 2

what the 10.echo count ("abc") will output ;

The count () function calculates the number of cells in an array or the number of attributes in an object, usually an array (), and for an object, if SPL is installed, you can invoke count () by implementing the countable interface. The interface has only one method count (), and this method returns the return value of the count () function.

If the parameter is not an array type or an object that implements the countable interface, it returns 1 with only one exception, and if the argument is null, the result is 0.

What is the difference between single and double quotes in 11.PHP? Which speed is faster?

Single quotes faster

The data in single quotes is not parsed (any variable and special escape character), so it is faster, and the data inside the double quotation marks is parsed, such as the variable ($var) values are taken into the string, and special escape characters are parsed into a particular single word.

Double quotes such as:

$name = ' Hello ';

echo "The $name";

Will output the $name

If it is a single quotation mark

$name = ' Hello '

Echo ' The $name '

Will output the Hello

12. Brief introduction of gbk,gbk2312,big5,gb18030

GB2312 support less Chinese characters, GBK is more rich than GB2312 Chinese characters, including all the Chinese and Japanese Korean characters, GB18030 compared to GBK added some ethnic Chinese character library more diverse, ordinary people rarely use, general Simplified Chinese use GBK and traditional Chinese use BIG5

13. Briefly describe the use of the empty () function

bool Empty ($var) if var the value is non-null or nonzero, empty () returns FALSE . In other words,"",0, NULL " FALSE 0",,,Array (),var $var; and objects that do not have any properties are considered empty, and if they are var empty, they are TRUE returned.

The use of the 14.is_null () function?

Detects if the variable is null, returns TRUE if it is null, otherwise returns FALSE. Usually variables are known to be null in three cases 1. is assigned a value of NULL2. has not been assigned a value of 3. be unset ().

15. What is the difference between an interface and an abstract class?

Abstract classes are classes that cannot be instantiated and can only be used as parent classes of other classes, and abstract classes are declared with the keyword abstract.

Abstract classes, like ordinary classes, contain member variables and member methods, the difference being that the abstract class contains at least one abstract method.

Abstract methods do not have a method body, the method is born to be overridden by the quilt class.

The format of the abstract method is: Abstr function Abstractmethod ()

The interface is declared by the interface keyword, the member constants and methods in the interface are public, and the method can not write the keyword public.

The method in the interface is also not the method body, the method in the interface is also born to be implemented by the quilt class.

Abstract class and interface implementation of the function is very similar, the biggest difference is that the interface can achieve multiple inheritance, in the application of the choice of abstract class or interface to see the specific implementation.

Subclass inherits abstract class using extends, subclass implements interface using implements.

Sort out some of the PHP interview topics

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.