PHP Face Test summary sharing

Source: Internet
Author: User
Tags abstract definition autoload gz file mysql commands php session php debug
This article is mainly to share with you the PHP test paper Summary, I hope to help everyone.

1. What is object-oriented? What are the main features?

Object-oriented is a design method of program, it is advantageous to improve the reusability of program, and make the program structure clearer. Main features: encapsulation, inheritance, polymorphism.

2. What is the difference between a SESSION and a cookie, and what are the reasons and effects that arise from the agreement?

1, HTTP stateless protocol, can not distinguish whether the user is from the same site, the same user request different pages can not be regarded as the same user.

2, the session is stored on the server side, the cookie is saved on the client. Session is more secure, cookies can be modified by some means, unsafe. The session relies on the cookie for delivery.

When a cookie is disabled, the session does not work properly. The disadvantage of the session: to protect the server side, each read from the server to read, the server has resource consumption. The session is saved in the file or database on the server side and is saved by default in the file, and the file path is specified by Session.save_path of the PHP configuration file. The session file is public.

3. What does the 302, 403, 500 code mean in HTTP status?

12345 principle: I. Message series two success series three. REDIRECT Series four. Request error series five. Server-side Error series

302: The temporary transfer succeeds, the requested content has been transferred to the new location 403: Forbidden 500: Server Internal Error 401 represents unauthorized.

4. Create a compressed package under Linux, unzip the package command

tar.gz:

Package: Tar czf file.tar.gz file.txt

Decompression: Tar xzf file.tar.gz

BZ2:

Package: bzip2 [-K] File

Decompression: bunzip2 [-K] File

Gzip (file only, do not keep the original file)

Package: gzip File1.txt

Decompression: Gunzip file1.txt.gz

Zip:-R to Directory

Package: Zip File1.zip file1.txt

Decompression: Unzip File1.zip

5. Please write the meaning of the data type (int char varchar datetime text); What is the difference between varchar and char?

Int integer char fixed-length character varchar variable-length-date-datetime-text-type varchar differs from char-char is a fixed-length character type, allocating much space and occupying much space. VARCHAR is a variable-length character type, the content of how much space to occupy, can effectively save space. Since the varchar type is mutable, the server has to perform additional operations when the length of the data changes, so the efficiency is lower than the char type.

6. What are the basic differences between MyISAM and InnoDB? How is the index structure implemented?

MyISAM types do not support transactions, table locks, easy to produce fragments, to be constantly optimized, read and write faster, while the InnoDB type supports transactions, row locks, there is crash recovery capability. Reading and writing speed is slower than MyISAM.

CREATE INDEX: alerttable tablename Add index (' field name ')

7. Do not use cookies to send a cookie to the client.

Understanding: When Session_Start () is turned on, a constant SID is generated, and when the cookie is turned on, the constant is empty, and when the cookie is closed, the value of PHPSESSID is stored in the constant. By adding a SID parameter after the URL to pass the value of the SessionID, the client page can use the value inside the session. When the client opens the cookie and server-side open session. The first time the browser requests, the server sends a cookie to the browser to store SessionID. When the browser requests a second time, it will

8. Isset () and empty () differences

Isset determine whether a variable exists, you can pass in multiple variables, if one of the variables does not exist then return false, empty to determine whether the variable is empty is false, can only pass a variable, if the empty is False then return true.

9. How do I pass variables (at least two ways) between pages? Get,post,cookie,session, Hide Form

1. Write a regular expression that matches the URL.

'/^ (https?| FTPs?): \ /\/(WWW) \. ([^\.\/]+)\. (com|cn|org) (\/[\w-\.\/\?\%\&\=]*)?/I '

2. Write a common sorting algorithm, and use PHP to sort the bubbles, sorting the array of $ A = array () in a small to large way.

Common sorting algorithm: Bubble Sort method, quick Sort method, simple choice sorting method, heap sorting method, direct insertion Sort method, Hill sort method, combined sort method.

The basic idea of the bubble sorting method is that the two records are exchanged when the order of the next two keywords is found to be the same as the ordered rules, and the sequential scan is performed from backward to forward (reverse). In this way, a record with a smaller keyword will gradually move from the back to the front, just as bubbles float in water, so the algorithm is also called bubble sequencing.

Bubble Sort Method Function Mysort ($arr) {for         ($i =0; $i <count ($arr); $i + +) {for                  ($j =0; $j <count ($arr)-$i; $j + +) {                           If ($arr [$j]> $arr [$j +1]) {                                    $tmp = $arr [$j];                                    $arr [$j]= $arr [$j +1];                                    $arr [$j +1]= $tmp;            }         }} Return$arr;} $arr =array (3,2,1);p Rint_r (Mysort ($arr));

3. Please indicate the difference between the value of the transfer and the reference in PHP. When is the value passed?
Pass by value: Any changes to values within the function scope are ignored outside the function

Pass by reference: Any changes to values within a function can also reflect these changes outside of the function

Pros and Cons: When passing by value, PHP must copy the value. This can be a costly operation, especially for large strings and objects. Passing by reference does not require copying values, which is good for performance gains.


What is the function of error_reporting in PHP?
Set the error level for PHP and return to the current level.


Use regular expressions (Regular expression) to write a function that verifies that the e-mail message is in the correct format.

if (Isset ($_post[' action ')) && $_post[' action ']== ' submitted ') {         $email =$_post[' email '];         if (!preg_match ("/^[0-9a-za-z-]+@[0-9a-za-z-]+ (\.[ 0-9a-za-z-]+) {1,3}$/", $email)) {                  echo" e-mail detection failed ";         } else{                  echo "e-mail detection Success";}         }

Write a two-dimensional array sorting algorithm function that can be universal and call PHP built-in functions (Array_multisort ())

Two-dimensional array sorting, $arr is the data, $keys is the sort of health value, $order is the collation, 1 is ascending, 0 is descending function array_sort ($arr, $keys, $order =0) {         if (!is_array ($ ARR)) {                  return false;         }         $keysvalue =array ();         foreach ($arr as$key = $val) {                  $keysvalue [$key] = $val [$keys];         }         if ($order = = 0) {                  asort ($keysvalue);         } else {                  arsort ($keysvalue);         }         Reset ($keysvalue);         foreach ($keysvalueas $key = = $vals) {                  $keysort [$key] = $key;         }         $new _array =array ();         foreach ($keysortas $key = = $val) {                  $new _array[$key] = $arr [$val];         }         return $new _array;}

Split the string ' Apple Orange bananastrawberry ' with a space as an interval, forming an array of $fruit,

* All elements in the array are in lowercase letters and sorted in alphabetical order

Class Sort {         private $str;         Public Function__construct ($STR) {                  $this->str=strtolower ($STR);         }         Private Functionexplodes () {                  if (empty ($this->str)) ReturnArray ();                  $arr =explode ("", $this->str);                  Return Is_array ($arr)? $arr: Array ($arr);         }         Public Functionsort () {                  $explode = $this->explodes ();                  Sort ($explode);                  return $explode;         }} $str = ' Apple Orange Banana Strawberry '; $sortob =new sort ($str); Var_dump ($sortob->sort ());

For the user to enter a string of strings $string, $string can only contain numbers greater than 0 and commas, please use regular expression validation, for non-compliant $string return error information

Class Regx {public         staticfunction check ($str) {         if (Preg_match ("/^ ([1-9,]) +$/", $str)) {                  return true;         }         return false;         }} $str = "12345,6", if (Regx::check ($STR)) {echo "suc";} else {echo "fail";}

Windows platform, Apache Http server startup failed, what is the troubleshooting idea?

Check that the 80 port used by Apache is occupied, and if it is occupied, stop the service that consumes 80 ports and start the Apache server


Where is the session data stored by default in the PHP session extension? D

A) SQLite Database

B) MySQL Database

C) Shared Memory

D) File System

E) Session Server

If you want to load the class automatically, which of the following function declarations is correct C

A) function AutoLoad ($class _name)

B) function __autoload ($class _name, $file)

C) function __autoload ($class _name)

D) function _autoload ($class _name)

E) function AutoLoad ($class _name, $file)

PHP program using UTF-8 encoding, the following program output is what? B

<?php$str = ' Hello World ', Echo strlen ($STR);? >

A) 9 B) (GBK) C) (D) (UTF8)

What do you know about PHP array-related functions?

Array ()----Create arrays

Array_combine ()----Create a new array by merging two arrays

Range ()----creates and returns an array containing the elements of the specified range

Compact ()----Create an array

The Array_chunk ()----splits an array into multiple

Array_merge ()----merge two or more arrays into an array

Array_slice ()----Remove a value in an array based on conditions

Array_diff ()----Returns an array of difference sets for two arrays

Array_intersect ()----computes the intersection of an array

Array_search ()----search for the given value in the array

Array_splice ()----Remove part of the divisor group and replace it

Array_key_exists ()----Determine if the specified key exists in an array

Shuffle ()----rearrange the elements in the array in random order

Array_flip ()----Exchange keys and values in an array

Array_reverse ()----flips the order of elements in the original array, creates a new array, and returns

Array_unique ()----To remove duplicate values from the divisor group

How does PHP read the contents of a file in several ways and functions?

Open the file, and then read. Fopen () fread ()

Open Read once complete file_get_contents ()

The following program, variable str What value is entered in case of 111?

if (! $str) {echo 111;}

The $STR value is: 0, ' 0′,false,null, ' "

What do you know about PHP technology (smarty, etc.)?

Smarty,jquery,ajax,memcache,p+css,js,mysqli,pdo,svn,thinkphp,brophp,yii

What are the PHP forum systems you are familiar with?

Discuz

What are the PHP marketplace systems you are familiar with?

Ecshop

What are the PHP development frameworks you are familiar with?

brophp,thinkphp

Tell me about your knowledge of caching technology.

1, caching technology is to cache the dynamic content into a file, in a certain time access to dynamic pages directly call the cache file, without having to re-access the database.

2, use memcache can do cache.

What are the design patterns you know?

Factory mode, strategy mode, single element mode, observer mode, command chain mode

Tell me about your knowledge of code management. What code version control software do you use most often?

Usually a project is developed by a team, each person will write their own code to the version of the server, by the project owner in accordance with the version of the management, convenient version control, improve development efficiency, to ensure that the need to return to the old version.

Common version controllers: SVN

Tell me about your understanding of SVN. Advantages and Disadvantages

SVN is a version controller that programmers develop code to submit to a version server for centralized management.

The advantages of SVN: code for centralized management, version control easy, simple operation, access control convenience.

Disadvantage: You cannot modify the server project folder arbitrarily.

How do I find the path to php.ini?

It is usually in the installation directory of PHP, or Windows directory of Window System.

PHP acceleration mode/extension? PHP debug mode/tool?

Zend Optimizer Accelerated expansion

Debugging Tools: Xdebug

What MySQL commands do you use?

Show databases

Show tables

Insert into table name () VALUES ()

Update table Name Set field = value where ...

Delete from table name where ...

Select * FROM table name where condition ORDER by ... DESC/ASC limit ... Group by ... Having ...

Go to the MySQL admin command line command?

Mysql-uroot-p Enter password

show databases; What is the purpose of this command?

Shows which databases are in the current MySQL server

Show CREATE database MySQL; What is the purpose of this command?

To display the SQL statement that created the database

Show create table user; What is the purpose of this command?

To display the SQL statement that created the table

DESC user; What is the purpose of this command?

Querying the structure of the user table

Explain select * from user; What is the purpose of this command?

Get Select related information

Show Processlist; What is the purpose of this command?

Show which threads are running

SHOW VARIABLES; What is the purpose of this command?

Display system variables and values

SHOW VARIABLES like '%conn% '; What is the purpose of this command?

Displays the value of the system variable name that contains the conn

Left JOIN write an SQL statement?

Selecta.id,a.class from A left JOIN B on a.cid=b.id

In, not NI, exist, not exist role and difference?

In what

Not in what

Exists exists

Not exists does not exist

How do I find the configuration file path for my database?

Under the database installation directory, My.ini

Describe the process of installing PHP under Linux?

Install the build tool before installing the software gcc, gcc-c++

Copy source package, unpack and unzip

cd/lamp/php into the PHP directory./configure–prefix=/usr/local/php–with-config-file-path=/usr/local/php/etc Specify the installation directory and configuration file directory make Compile make install installation A brief description of the process of installing MySQL under Linux? Groupadd MySQL Add a user group Mysqluseradd-gmysql mysql add a MySQL user specified group to mysqlcd/lamp/mysql into MySQL directory./configure–prefix=/usr /local/mysql/–with-extra-charsets=allmakemake all describe the process of installing Apache under Linux? CD/LAMP/HTTPD go inside the Apache software catalog./configure–prefix=/usr/local/apache2/–sysconfdir=/etc/httpd/– With-included-aprmakemake allhtml/css/p/javascritp:1. Design a page (4 p The first p width 960px Center; 第2-4个 P 3 divide 960px;) <style>Body{Text-align:center; margin:0; padding:0; } #box {width:960px; margin:0 Auto; }.small{width:320px; Float:left; }</style><pid= ' box ' ><pclass= ' small ' ></p><pclass= ' small ' ></p><pclass= ' Small ' ></p></p> use JavaScript to get a value for input? Get a property of input? document.getElementById (' name '). Value;document.getelementbyid (' name '). Type; use jquery to get a value for input? Get a property of input? $ ("Input[name= ' AA ']"). Val (); $ ("Input[name= ' AA ')"). attr (' type '); Please write a section of AJMicrosoft Dynamics AX commits the JS code, or writes out the process logic of the AJAX submission. var xmlhttp;if (window. Xmlhttprquest) {xmlhttp=newxmlhttprequest ();} ElseIf (window. ActiveXObject) {xmlhttp=newactivexobject (' microsoft.xmlhttp ');} Xmlhttp.open (' GET ', ' 1.php?aa=name ', true); Xmlhttp.onreadystatechange=function () {if (xmlhttp.readystate==4) {if ( xmlhttp.status==200) {var text=xmlhttp.responsetext;}}} Xmlhttp.send (NULL);

Brief introduction of cookie setting and acquisition process

Set the value of the cookie:

Setcookie (name, value, save time, valid domain);

Get value: $_cookie[' name '];

The difference between an object-oriented interface and an abstract class and its application scenario?

1, the abstract method of the class is called abstract class, abstract classes are not necessarily abstract methods, abstract methods must use the abstract keyword definition.

2, the interface is all abstract method, the method does not use the abstract definition.

3, when a number of similar classes to design an upper layer, usually designed as an abstract class, when multiple heterogeneous classes to design an upper layer, usually designed as an interface.

Object-oriented implementation of object A to inherit B and C objects

Interface b{...}

Interface c{...}

Class aimplements b,c{...}

Related recommendations:

Algorithm problem of PHP face question

An analysis of object-oriented topics in PHP interview questions

One of the most error-prone 10 php face questions

Related Article

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.