Home > Backend Development > PHP Tutorial > PHP interview question set, PHP test questions_PHP tutorial

PHP interview question set, PHP test questions_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:16:56
Original
974 people have browsed it

PHP interview question set, PHP test questions

Han~~ I did some PHP questions on the Internet, and I have reached this point without realizing it... Post the answers
If you have any questions, please feel free to add and correct me

1. Use PHP to print out the time of the previous day in the format of 2006-5-10 22:21:21 (2 points) ​ $a = date("Y-m-d H:i:s", strtotime("-1 day")); print_r($a);

​ 2. The difference between echo(), print() and print_r() (3 points) ​ echo and print are not a function, but a language structure int print(string $arg), only one parameter echo arg1,arg2; can output multiple parameters and return void echo and print can only print out strings, not structures. print_r can print out the structure for example $arr = array("key"=>"value"); print_r($arr);

​ 3. Templates that enable HTML and PHP to be used separately (1 point) smarty,phplib

​ 4. What tools are used for version control? (1 point) svn,git,cvs

​ 5. How to implement string flipping? (3 points) English: strrev($a) ​ Chinese or other text: ​ Chinese: GB2312, the code is encoded using GB2312 len=mbst rwidth(str,"GB2312"); for(i=0;i< len;i++) { arr[]=mb substr(str, $i, 1, "GB2312"); } return implode("", array_reverse($arr)); } print_r(reverse("Hello"));

​ -------------------------------------------------- ------------- ​ 6. Methods to optimize MYSQL database. (4 points, write more and get more) ​ In terms of sentences: 1 Use indexes to increase query efficiency 2 Optimize query statements and improve index hit rate ​ Database aspects involved: 1 Construct sub-databases and tables to improve the storage and expansion capabilities of the database 2 Use different storage engines as needed

​ 7. The meaning of PHP (send 1 point) ​ hypertext preprocessing language Hypertext PreProcessor

​ 8. What is the function that MYSQL uses to obtain the current time?, and the function that formats dates is (2 points) CURRENT_TIMESTAMP() DATE_FORMAT() select DATE_FORMAT("2011-11-21 10:10:10", "%Y-%m-%d");

​ ​ 9. A method to intercept Chinese text strings without garbled characters. (3 points) mb_substr($str, 1, 1, "GB2312");

​ -------------------------------------------------- ------------- ​ 10. Have you ever used version control software? If so, what is the name of the version control software you used? (1 point) svn git

​ 11. Have you ever used a template engine? If so, what is the name of the template engine you used? (1 point) smarty

​ 12. Please briefly describe your most proud development work (4 points) XXX

​ 13. For websites with large traffic, what methods do you use to solve the traffic problem? (4 points) 1 Effectively use cache to increase cache hit rate 2 Use load balancing 3. Use CDN to store and accelerate static files 4 ideas to reduce database usage 5 Check where the statistical bottlenecks are

​ -------------------------------------------------- --------------- ​ 14. Use PHP to write the code to display the client IP and server IP 1 point) $_SERVER["REMOTE_ADDR"] $_SERVER["SERVER_ADDR"]

​ 15. What is the difference between the include and require statements? To avoid including the same file multiple times, they can be replaced by (?) statements? (2 points) On failure: include generates a warning, while require generates an error interrupt directly. ​ require is loaded before running include is loaded at runtime ​ require_once include_once

​ 16. How to modify the survival time of SESSION (1 point). session_set_cookie_params

​ ​ 17. There is a web page address, such as the PHP Research Laboratory homepage: http://www.phpv.net/index.html, how to get its content? ($1 point) file_get_contents ​ curl

​ 18. In HTTP 1.0, the meaning of status code 401 is (?); if the prompt "File not found" is returned, the header function can be used, and its statement is (?); (2 points) Unauthorized ​ header("HTTP/1.0 404 Not Found"); ​ In fast CGI: header("Status: 404 Not Found");

​ ​ 19. In PHP, heredoc is a special string, and its end mark must be? (1 point) appear in pairs $a = <

​ 20. Talk about the advantages and disadvantages of asp, php and jsp (1 point) asp needs to rely on IIS and is a language developed by Microsoft php and jsp can rely on other servers such as apache or nginx

​ 21. Talk about your understanding of mvc (1 point) model: data structure layer view: display control: receive and judge processing input

​ ​ -------------------------------------------------- ------------------ ​ 22. Write the SQL of the names of the ten people with the most posts, using the following table: members (id, username, posts, pass, email) (2 points) select top 10 id,username from members order by posts desc

​ 23. Please explain the difference between passing by value and passing by reference in PHP. When to pass by value and when to pass by reference? (2 points) & means passing by reference Passing parameters by reference in a function will change the parameters Generally, you can consider using references when there are multiple output parameters.

​ 24. What is the function of error_reporting in PHP? (1 point) Set the display level of error

​ 25. Please write a function to verify whether the format of the email is correct (2 points) $str = "jianfeng@126.com"; regex="( [az09.]+)@([daz.]+).([az.]2,6) " ; //Regular return preg_match(regex,str)

​ ​ 26. Briefly describe how to get the current execution script path, including the obtained parameters. (2 points) $argc -- Get the number of parameters $argv -- Get the parameter list

​ 27. How to modify the survival time of SESSION. (1 point) session_set_cookie_params

-------------------------------------------------- ------------------ ​ 28. What is the function to pop up a dialog box in a JS form? What is the function to get input focus? (2 points) alert() confirm() prompt() ​ focus()

​ 29. What is the redirection function of JS? How to introduce an external JS file? (2 points) window.location.href="#" ​

​ 30. What is the difference between foo() and @foo()? (1 point) @ represents all warnings to be ignored

​ 31. How to declare a class named "myclass" without methods and attributes? (1 point) class myclass { }

​ 32. How to instantiate an object named "myclass"? (1 point) $myclass = new myclass();

​ 33. How do you access and set the properties of a class? (2 points) n=a->name; print_r($n);

​ 34. What is the difference between mysql_fetch_row() and mysql_fetch_array? (1 point) mysql_fetch_array() is an extended version of mysql_fetch_row(). In addition to storing data in an array as a numerical index, you can also store data as an associative index, using the field name as the key.​ ​ row=mysqlfetcharray( result, MYSQL_ASSOC)) {
printf ("ID: %s Name: %s", row["id"],row["name"]); } ​ Mysql_free_result($result);

​ -------------------------------------------------- ------------------ ​ 35. What is the GD library used for? (1 point) Dynamic and open image processing library

​ 36. Point out some ways to enter a piece of HTML code in PHP. (1 point) echo "{html}" echo <

​ 37. Which of the following functions can open a file for reading and writing? (1 point) c (a) fget() (b) file_open() (c) fopen() (d) open_file()

​ 38. Which of the following options does not add john to the users array? (1 point) b (a) $users[] = ‘john’; ​(b) array_add($users,’john’); (c) array_push($users,‘john’); (d) $users ||= ‘john’;

​ 39. Will the following program be input? (1 point) 10 ​$num = 10; function multiply(){ num=num * 10; } ​multiply(); echo $num; ?>

​ 40. Use PHP to write a simple query to find out all the content named "Zhang San" and print it out (2 points) Table Name UserName Tel Content Date Zhang San 13333663366 Graduated from college 2006-10-11 Zhang San 13612312331 Undergraduate degree 2006-10-15 Zhang Si 021-55665566 Graduated from technical secondary school 2006-10-15 Please complete the code according to the above questions: ​$mysql_db=mysql_connect("local","root","pass"); ​@mysql_select_db("DB",$mysql_db); $sql = sprintf("select * from %s where UserName = '%s'", "table name", "Zhang San"); values=mysqlquery( sql); while(item=mysq lfetchqueryarray(values)) { echo sprintf("Username: %s, phone number %s, education: %s, graduation date: %s", item[Us erName],item['Tel'], item[C ontent],item ['Date'] ); }

​ 41. How to use the following classes and explain what they mean? (3) class test{ ​function Get_test($num){ num=md5(md5(num)."En"); ​return $num; } } $test = new test(); ret=test-> Get_test(11); print_r($ret);exit; ​ Connect the 32-bit string a1 generated after MD5 encoding of num with "En" and then perform MD5 encoding again.

-------------------------------------------------- -------------------------- ​ 42. Write the format of SQL statements: insert, update, delete (4 points) Table Name UserName Tel Content Date Zhang San 13333663366 Graduated from college 2006-10-11 Zhang San 13612312331 Undergraduate degree 2006-10-15 Zhang Si 021-55665566 Graduated from technical secondary school 2006-10-15 (a) There is a new record (Xiao Wang 13254748547 graduated from high school 2007-05-06). Please use SQL statements to add it to the table. insert into table name values('Xiao Wang', '13254748547', 'High School Graduation', '2007-05-06') ​ (b) Please use sql statement to update Zhang San’s time to the current system time update table name set Date = GETDATE() where UserName = "Zhang San" ​ (c) Please write to delete all records named Zhang Si delete from indicates where UserName = "Zhang Si"

​ 43. Please write the meaning of data type (int char varchar datetime text); what is the difference between varchar and char (2 points) int integer type char storage fixed length varchar storage variable length datetime time text stores variable length ​ varchar is variable length char(20) fixed length

​ 44. MySQ auto-increment type (usually table ID field) must be set to (?) field (1 point) auto_increment ​ 45. Write the output of the following program (1 point) ​$b=201; ​$c=40; ​a=b>$c?4:5; echo $a; ?> ​ 4

​ 46. ​​Is there a function that detects whether a variable is set? What is the function that detects whether it is empty? (2 points) isset() empty()

​ -------------------------------------------------- -------------------------- ​ 47. What is the function to obtain the total number of query result sets? (1 point) mysql_num_rows()

​ 48. $arr = array('james', 'tom', 'symfony'); Please print out the value of the first element (1 point) print_r($arr[0]); ​ reset($arr); print_r(current($arr)); ​ print_r(array_shift($arr));

​ 49. Please separate the values ​​of the array in question 41 with ',' signs and merge them into string output (1 point) implode

​ 50. a=abcdef;Pleasetakeout The value of a and print out the first letter (1 point) $a[0]; ​ substr($a, 0, 1);

​ 51. Can PHP be connected to databases such as sql server/oracle? (1 point) Can There are ready-made libraries

​ 52. Please write the PHP5 permission control modifier (3 points) public private protected

​ 53. Please write the constructor and destructor of php5 (2 points) public function __construct() { } ​ public function __destruct() { }

​ Programming questions ​ ​ 1. Write a function to retrieve the file extension from a standard URL as efficiently as possible For example: http://www.sina.com.cn/abc/de/fg.php?id=1 needs to remove php or .php ​ arr=pars eurl( url); pathArr=pathinfo(arr['path']); print_r($pathArr['extension']);

​ 3. Write a function to calculate the relative paths of two files For example $a = '/a/b/c/d/e.php'; ​$b = '/a/b/12/34/c.php'; Calculate b phase versus in a The relative path should be http://www.cnblogs.com/ 12/34/c.php will be added

  path, conpath) { pathArr=expode("/",path); conpathArr=explode("/",conpath); $dismatchlen = 0; for(i=0;i < count(pahrr) ;i++) { if(conpthAr r[i] != pathArr[i]) { dismatchlen=count(pathArr) - $i; arrLeft=arrayslice(pathArr, $i); break; } } ret=strrepeat("../",dismatchlen).implode("/", $arrLeft); return $ret; }   print_r(sGetRelativePath(b,a));

 

      3.写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。

 

handle=opendir(folder);
while((file=readdir(handle)) !== false) { //如果是.或者..则跳过 if(file=="."||file == "..") { continue; } if(is_file(folder."/".file)) { aFileArr[]=file;  }else if(is_dir(folder."/". file)) { aFileArr[file] = aGetAllFile(folder."/".file); } } closedir($handle); } return $aFileArr; } ​ $path = "/home/test/sql"; print_r(aGetAllFile($path));

PHP programmer computer interview questions (with answers, bonus points for good answers)

PHP interview questions from a large company

Management reminder: This post was unpinned by haowubai (2009-07-30)
1. How to use PHP environment variables to get a web page address content? How to get the ip address?
[php]
echo $_SERVER ['PHP_SELF'];
echo $_SERVER ['SERVER_ADDR'];
[/php]

2. Find the two dates Difference, such as the date difference from 2007-2-5 ~ 2007-3-6
[php]
$begin=strtotime('2007-2-5');
$end=strtotime( '2007-3-6');
echo ($end-$begin)/(24*3600);
[/php]

3. Please write a function to implement the following functions :
The string "open_door" is converted into "OpenDoor", "make_by_id" is converted into "MakeById".
[php]
function changeStyle(& $str) {

/*$str = str_replace ( "_", " ", $str );
$str = ucwords ( $ str );
$str = str_replace ( " ", "", $str );
return $str;*/

$arrStr=explode('_',$str);
foreach($arrStr as $key=>$value){
$arrStr[$key]=strtoupper(substr($value,0,1)).substr($value,1);
}
return implode('',$arrStr);
}
$s = "open_door";
echo changeStyle ( $s );
[/php]

4. It is required to write a program to convert the following array $arr1 into array $arr2:
[php]$arr1 = array (
'0' => array ('fid' => 1, ' tid' => 1, 'name' =>'Name1' ),
'1' => array ('fid' => 1, 'tid' => 2 , 'name' => ;'Name2' ),
'2' => array ('fid' => 1, 'tid' => 5 , 'name' =>'Name3' ),
'3' => array ('fid' => 1, 'tid' => 7 , 'name' =>'Name4' ),
'4' => array ('fid' => 3 , 'tid' => 9, 'name' =>'Name5' )
);
$arr2 = array...The rest of the text>>

PHP interview questions? Hurry

Friends who are looking for a job can take a look, but don’t think that these are necessarily useful. Sometimes work experience is also very important. However, the basic knowledge points are still very important. As for the algorithmic issues in high-level, if you are not doing particularly important tasks, you will not encounter these algorithms (except for online games); in high-level photo album processing, if you can really handle it, you can do it alone Selling a product is not a problem.

1. Basic knowledge points
The meanings of several status codes in the HTTP protocol: 503 500 401 200 301 302
The difference between Include require include_once require_once.
Several versions in PHP/Mysql The evolutionary history, such as major improvements from mysql4.0 to 4.1, PHP 4.x to 5.1, etc.
Introduction to HEREDOC
Write some PHP magic methods;
Some configure parameters when compiling PHP
Two ways to pass parameters to PHP.
(mysql) Please write the meaning of the data type (int char varchar datetime text); What is the difference between varchar and char;
Error_reporting and other debugging functions are used
Have you ever used version control software? If so What is the name of the version control software you use?
The difference between posix and perl standard regular expressions;
What are the restrictions after Safe_mode is turned on.
Write code to solve the problem of multiple processes/threads reading and writing a file at the same time problem.
Write a piece of code to upload files.
Mysql storage engine, the difference between myisam and innodb.

2. Web architecture, security, project experience
Introducing the experience of using xdebug, apc, eAccelerator, Xcache, Zend opt.
Use mod_rewrite, when there is no physical file /archivers/567.html on the server, redirect to index.php?id=567, please turn on mod_rewrite first.
MySQL database is used as the storage of the publishing system, five times a day The increment of more than 10,000 items is expected to be operated and maintained for three years. How to optimize it?
Write a sorting algorithm (principle) and tell how to optimize it.
Please briefly describe your most proud development work
For high-traffic websites, what method do you use to solve the statistical problem of page visits
Have you ever used a template engine? If so, have you used it? What is the name of the template engine?
Please introduce the principle of Session, and what should be paid attention to in terms of Session in large websites?
Tools for testing PHP performance and MySQL database performance, and methods to find bottlenecks.
Regularly proposes all links in a web page.
Introducing the principles of common SSO (single sign-on) solutions (such as dedecms integrating discuz's passport).
The characteristics of the PHP framework you have written, what problems it mainly solves, and its differences from other frameworks.
What are the differences in performance optimization between large forums/news article systems/SNS websites?
Photo album applications: multiple files are required to be selected and uploaded at the same time in the browser, and pictures are required to be cropped and compressed in Server-side decompression. Can upload a single file up to 50M. A progress bar is displayed during the upload process. Thumbnails of four sizes can be generated for each picture, and the video files must be converted into flv for flash playback. Describe the various types of open source software to be covered and their simple uses.
A group of monkeys line up in a circle and are numbered according to 1, 2,..., n. Then start counting from the 1st one, count to the mth one, kick it out of the circle, start counting from behind it, count to the mth one, kick it out..., and continue in this way until the end. Until there is only one monkey left, that monkey is called the king. Programming is required to simulate this process, input m, n, and output the number of the last king. Use a program to simulate this process.

3. Basic use of unix/linux
Some methods to check the current system load information under Linux.
Basic shortcut keys for vim.
SSH security enhancement method; configuration of password mode and rsa key mode.
rpm/apt&...the rest of the text>>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/896708.htmlTechArticlePHP interview questions collection, PHP test questions~~ I did some PHP questions on the Internet, and I did it without knowing it Now...post the answer. If you have any questions, please feel free to add and correct me. 1. Use PHP to print out the previous one...
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