PHP interview questions for large companies, company PHP interview questions_PHP tutorial

WBOY
Release: 2016-07-13 10:16:09
Original
1843 people have browsed it

PHP interview questions from large companies, company PHP interview questions

1. Can SEESION still work after disabling COOKIE?

2. To capture remote images locally, what function would you use?

4. Do you think LUNIX is much faster than WIN under the same configuration at pV10W?

5. Briefly describe the maximum capacity of pOST and GET transmission respectively?

6. Write a function that finds the maximum value of 3 values ​​with the least amount of code.

Part of the answer is attached (not guaranteed to be the correct solution)

1. Cannot
2 fsockopen

4 (Same without optimization)
5 2MB,1024B
6 function($a,$b,$c){
return $a>$b? ($a> $c? $a : $c) : ($b>$c? $b : $c );
}

——————————————————————————————

pHp interview questions from large companies

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

3. Please write a function to achieve the following functions:
Convert the string "open_door" to "OpenDoor", "make_by_id" to "MakeById".
function str_change($str) {
$str = str_replace ( “_”, ” “, $str );
$str = ucwords ( $str );
$str = str_replace ( ” ", "", $str );
return $str; }

4. It is required to write a program to convert the following array $arr1 into array $arr2:
$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 (
'0′ => array (
'0′ => ; array ( 'tid' => 1, 'name' => 'Name1′),
'1′ => array ( 'tid' => 2, 'name' => 'Name2' ),
'2′ => array ( 'tid' => 5, 'name' => 'Name3′),
'3′ => array ( 'tid' => 7 'name' => Name5′ ) ) );

$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′ )
);
function changeArrayStyle($arr){
foreach($arr as $key=>$value){
$result[$value[fid]][] =$value;
}
return array_values($result);
}
$arr2=changeArrayStyle($arr1);
echo “

”;
var_dump( $arr2);
?>

5. Please briefly describe the paradigm and application of database design.

Generally, the 3rd normal form is sufficient for optimizing the table structure. This can not only avoid the application being too complex, but also avoid the inefficiency of the system caused by too large SQL statements.

ANSWER:
First normal form: If each attribute of the relational pattern R cannot be decomposed, it belongs to the first normal form.
Second normal form: If R belongs to the first normal form and all non-code attributes are completely functionally dependent on the code attributes, it is in the second normal form.
Third normal form: If R belongs to the second normal form, and none of the non-code attributes is a transfer function that depends on the candidate code, then it belongs to the third normal form.

6. There are multiple records of Id in a table. Find out all the records of this id and display the total number of records. Use SQL statements, views, and stored procedures to implement this.
Store procedure:
DELIMITER //
create procedure proc_countNum(in columnId int,out rowsNo int)
begin
select count(*) into rowsNo from member where member_id=columnId;
end
call proc_countNum(1,@no);
select @no;

View:
create view v_countNum as select member_id,count(*) as countNum from member group by member_id
select countNum from v_countNum where member_id=1

7 There are three columns A, B, and C in the table, which is implemented using SQL statements: when column A is greater than column B, select column A, otherwise select column B, when column B is greater than column C, select column B, otherwise select column C.
select
case
when first_name>middle_name then
case when first_name>last_name then first_name
else last_name end
else
case when middle_name>last_name then middle_name else last_name
end
end as name
from member

8 Please briefly describe the method of optimizing the execution efficiency of SQL statements in the project. From what aspects, how to analyze the performance of SQL statements?
SQL optimization is useless, it is better to add index directly.

9 If the template is a smarty template. How to use section statement to display an array named $data. For example:
$data = array(
[0] => array( [id]=8 [name]='name1′)
[1] => array( [id]=10 [name]='name2′)
[2] => array( [id]=15 [name]='name3′)
......
)
Write out the template page Code? How to display it if using foreach statement?
{section name=loop loop=$data}
{$data[loop].id}
{$data[loop].name}
{/section}

{foreach from=$data item=id key=k}
{$k} – {$id}
{/foreach}

10 Write a function that can traverse all files and subfolders in a folder. (Directory operation)
$d = dir(dirname(__file__));
//echo “Handle: ” . $d->handle . “\n”;
//echo “path: ” . $d->path . “\n”;
while ( false !== ($entry = $d->read ()) ) {
echo $ entry . “
”;
}
$d->close ();
?>
11 Two tables, city table and province table. They are the relationship tables between cities and provinces respectively.
city:
id City provinceid
1 Guangzhou1
2 Shenzhen1
3 Huizhou1
4 Changsha2
5 Wuhan3
…………. Guangzhou
province:
id province
1 Guangdong
2 Hunan
3 Hubei
………….
(1) Write a sql statement to relate two tables to achieve: display cities basic information. ?
(2) Display fields: city id, city name, province.
For example:
Id (city id) Cityname (city name) privacy (province)
. . . . . . . . .
. . . . . . . . .
(2) If you want to count how many cities there are in each province, please use group by to query it. ?
Display fields: province id, province name, how many cities it contains.
ANSWER:
1.select A.id,A.Cityname,B.province from city A,province B where A.provinceid=B.id
2.select B.id,B.province, count(*) as num from city A,province B where A.provinceid=B.id group by B.id
12. Based on your experience, please briefly describe the steps of software development in software engineering. Which of the following tools have you used, Rational Rose, powerDesigner, project, VSS or CVS, and TestDirector? What are the disadvantages?
The company uses dbdesigner and cvs, and the test management tool is Mantis
13. Please briefly describe the difference between threads and processes in the operating system. List the software you have used under LINUX?

14. Please use pseudo language combined with data structure bubble sorting method to sort the following set of data 10 2 36 14 10 25 23 85 99 45.

$a = array(10,2,36,14,10,25,23,85,99,45);
for($j=0 ; $j<9 ; $j++)
for($i=0 ; $i<9-$j ; $i++)
if($a[$i] > $a[$i+1]) {
$t = $a[ $i] ;
$a[$i] = $a[$i+1] ;
$a[$i+1] = $t ; }
echo var_dump($a);
————————————————————————————

————————————————————————————

————————————————————————————

Sina PHP Engineer Interview Questions Collection
1. The connection and difference between COOKIE and SESSION. How do multiple web servers share SESSION?
2. What is the difference between pOST and GET in HTTP protocol?
3. A piece of php code to write the output result:
/****THIS APP****/
$a=0;
$b=0;
if(($a= 3)>0||($b=3)>0){
$a++;
$b++;
echo $a;
echo $b; //Output the value of b ($a=4,$b=1) $b=3 is not executed
}
4. The include of request can include files. What is the difference between the two?

5. What is the principle of WEB uploading files in PHP, and how to limit the size of uploaded files?
is_uploaded_file() and move_uploaded_file()

6. Write a function that can traverse all files and folders in a folder.
7.8. There are a few unix shell questions in the middle (it seems to be two). I can’t remember them because I don’t understand them. Question
9. There is a document called mail.log. The content is a number of email addresses, in which the email addresses are separated by '\n'. Request to select the email address of sina.com (including reading from the file, filtering to printing).
mail.log content is as follows:
james@sina.com.cn
jack@163.com
zhansan@sohu.com
lisi@hotmail.com
wangwu@gmail. com

10. Code for forward and backward web pages in js (forward: history.forward();=history.go(1); backward: history.back();=history.go(-1); )
11. If window (B) is opened with window.open() in window (A), how to call the content in window A from window B? A and B are just the code names of the windows, not the names of the windows
12. Do you understand ajax? Have you ever used it? ……
13. What is MVC? Have you ever used it? What problems did you encounter during use and how did you solve them?
14. Write out the message header required to access http://www.sina.com.cn. Hey, this is what Super Pig remembered. md5_file()

————————————————————————————

————————————————————————————

————————————————————————————

The latest Sina pHp interview questions (2009.3)

1. echo count(“abc”); What does it output?
Answer: 1

2. Use pHp to write the code to display the client IP and server IP
Answer: client getenv('REMOTE_ADDR');
server side getenv('SERVER_ADDR'); // gethostbyname("www .baidu.com”);

3. What does error_reporting(2047) do?
Answer: Equivalent to error_reporting(‘E_ALL’); output all errors

4. How to realize pHp and JSp interaction?

The question is a bit vague. SOAp, XML_RpC, Socket function, and CURL can all achieve these. If you are testing the integration of pHp and Java, pHp has this built-in mechanism (if you are testing the integration of pHp and .NET, this can also be done) answer), for example $foo = new Java('java.lang.System');

5. What parameters will be affected by turning on Safe_mode in php.ini? Name at least 6.
Answer: When this module is opened, PHP will check whether the owner of the current script is the same as the owner of the file being operated. Therefore, it will affect file operation functions and program execution functions (program Execution Functions). These functions include .pathinfo, basename, fopen, system, exec, proc_open and other functions;

7. Please write a function to verify whether the format of the email is correct (regex is required)
function checkEmail($mail){

$reg = '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/';
$rst = preg_match($reg , $mail);
if($rst){
return TRUE;
}else {
return FALSE;
}
}

11. Write a function to sort a two-dimensional array.
array_multisort()

12. Write 5 different functions of your own to intercept the file extension of a full path, allowing to encapsulate existing functions in the php library.

13. 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

7. Methods to optimize MYSQL database.

(1). In terms of database design, this is the responsibility of the DBA and Architect. Design a well-structured database. When necessary, denormalize it (English is this: denormalize, I don’t know the Chinese translation), allowing some Data redundancy avoids JOIN operations to improve query efficiency
(2). In terms of system architecture design, table hashing is used to hash massive data into several different tables. Fast and slow tables only retain the latest data. , the slow table is a historical archive. Cluster, master server Read & write, slave server read only, or N servers, each machine is Master for each other
(3). (1) and (2) exceed the requirements of the pHp programmer , it will be better, it doesn’t matter. Check whether there are fewer indexes
(4). Write efficient SQL statements and see if there are any inefficient SQL statements, such as full joins that generate Cartesian products, a lot Group By and order by, no limit, etc. When necessary, encapsulate the database logic into the stored procedure on the DBMS side. Cache the query results and explain each SQL statement
(5). All the results are required, only from the database Get the necessary data, such as querying the number of comments on an article, select count(*) ... where article_id = ? That's it. Don't select * ... where article_id = ? first, and then msql_num_rows.
only transmit the necessary SQL statements. For example, when modifying an article, if the user only modified the title, then... set title = ? where article_id = ? Do not set content = ? (large text)
(6). Use a different storage engine when necessary. For example InnoDB can reduce deadlocks. HEAp can increase query speed by an order of magnitude

————————————————————————

$s = 'abc';
if ($s==0)
echo 'is zero
';
else
echo 'is not zero
';
?>

Many people answered wrongly, thinking that the answer is to output the string "is not zero". In fact, the correct answer should be to output the string "is zero".

The reason is actually simple, because pHp is a weakly typed language. It has no mandatory requirement that variables "must be defined first before using". The type of variables can also be flexibly changed according to the type of assignment. This "flexibility" seems flexible, but in fact it creates hidden dangers of errors. Although the $s = 'abc'; statement defines the variable $s as a string type, because in the if ($s==0) ​​statement, $s is compared with a numeric constant, so $s is implicit at this time Converted into a numeric variable, its value is 0, so the result of $s==0 comparison is true.

People who make this type of mistake are usually programmers who switch from Java, C and other languages ​​to pHp development. Because Java, C and other languages ​​are strongly typed languages, they do not allow different types of variables and constants to be compared with each other. In this case a syntax error is reported.

In fact, the developers of the pHp language are not unaware of this kind of problem. There is also a strict comparison operator "===" in the pHp language, which requires that the two sides of the comparison must be of the same type. The above if ($s ==0) If the statement is written as if ($s===0), the above error will be avoided.

——————————————————————————————

$str=”cd”;

$$str=”hotdog”; //$cd

$$str.=”ok”;

echo $cd; //hotdogok

?>

——————————————————————————————-
9. How to achieve maximum load with apache+mysql+php
The main reason is that the configuration file has been optimized. In addition, running on Linux is better than running on Windows.

mkdir creates a directory touch creates a folder Modify permissions chmod and the like

51. Please write the pHp5 permission control modifier (3 points)
private protected public

13. For a website with large traffic, what method do you use to solve the traffic problem? (4 points)
First, confirm whether the server hardware is sufficient to support the current traffic
Second, optimize database access.
Third, external hotlinking is prohibited.
Fourth, control the download of large files.
Fifth, use different hosts to divert the main traffic
Sixth, use traffic analysis and statistics software.

The htmlspecialchars() function converts some predefined characters into HTML entities.

The

htmlentities() function converts characters into HTML entities. (The escaping of htmlentities( ) is more thorough.)
SQL injection is easy to avoid. As mentioned in Chapter 1, you must insist on filtering input and escaping output. ————

microtime returns the current timestamp, mktime() gets the specified timestamp

//The address of this page, the name of the current script.
echo $_SERVER[pHp_SELF].”
”;
//The URL address of the previous page linked to the current page:
echo $_SERVER[HTTp_REFERER].”
”;

3. In HTTP 1.0, the meaning of status code 401 is (4); if a "File not found" prompt is returned, the header function can be used,

The statement is (5).
(4) Unauthorized (5) header(“HTTp/1.0 404 Not Found”);——File not found
header(“HTTp/1.1 403 Forbidden”);——Access not allowed

7. Install pHp as an Apache module. In the file http.conf, first use statement (10) to dynamically load the pHp module,
and then use statement (11) to make Apache install all extensions with php Files are processed as pHp scripts.
(10) LoadModule php5_module “c:/php/php5apache2.dll”
(11) AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php . php5 .php4 .php3 .phtml

9. The attributes of the class can be serialized and saved to the session, so that the entire class can be restored later. The function to be used is (14).
serialize() /unserialize()

10. The parameter of a function cannot be a reference to a variable, unless (15) is set to on in php.ini.
allow_call_time_pass_reference

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>>

Are PHP interview questions usually written in writing or answered on a computer?

There is no handwriting in the written test, it is all done on a computer. The interview means asking about basic knowledge or looking at your previous works

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/898819.htmlTechArticle PHP interview questions for large companies, company PHP interview questions 1. Can SEESION still be used after disabling COOKIE? 2. What function would you use to capture remote images locally? 4. Do you think that in pV10W, the same configuration...
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