Home  >  Article  >  Backend Development  >  It is said to be Sina Leju’s interview questions and my answers as well as some suggestions for written test questions.

It is said to be Sina Leju’s interview questions and my answers as well as some suggestions for written test questions.

WBOY
WBOYOriginal
2016-07-29 08:56:101098browse
1.
1. There is the following HTML:
1) Use js to obtain the ________ method to obtain the object;
2) Use the ________ attribute to get the attribute value of the attribute title;
3) Use the ________ method to get the attribute value of the attribute sina_title;
(1) document.getElementById('img1');
(2) document.getElementById('img1').getAttribute('title');
(3) document.getElementById('img1').getAttribute('sina_title');
2. Pair array in php The serialization and deserialization functions are ______ and _______ respectively;
serialize, upserialize
3. The difference between rawurlencode and urlencode functions is ____________________;
rawurlencode will convert spaces to +, urlencode will convert spaces into %20
4. The function to filter HTML in php is _______, and the escaping function is ____________;
strip_tags,htmlspecialchars
5. Write out the js in HTML using regular expressions Scripts are filtered out;
preg_replace('//is','',$htmlcode);
6. The meaning of LEFT JOIN in SQL is ______________;
if There is a table tl_user that stores student ID and name, and another table tl_score that stores student ID, subject and score (some students do not have test scores). Write a sql statement to print out the student's name and total score of each subject;
A left join first takes out all the data from the left table, and then takes out the data from the right table that satisfies the where condition. When the data in this row does not meet the where condition, it returns empty.
select tu.name,sum(ts.score) as totalscore from tl.user left join tl_score on tl.uid = ts.uid;
7. Write three functions that call system commands;
system, passthru, exec
8. Josn’s function for processing arrays is;
json_encode, json_decode
9. Determine whether a variable is set in PHP The function is_______; the one that determines whether it is empty is___________;
isset, empty
10. The difference between error_reporting("E_ALL") and ini_set("display_errors", "on")_________;
The former is to set the error display level, and E_ALL means to prompt all errors (including notice, warning and error). The latter is to set php to display errors. In the error display control, the latter has the highest priority.
11. PHP writes the predefined variable _________ that displays the client IP; the source URL is provided by __________;
$_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_REFERER']
12 , The function that PHP uses to convert UTF-8 to gbk is___________;
iconv('UTF-8','GBK',$str);
13. The function that splits a string into an array in PHP__________ , what connects numbers to form a string is _______;
explode,implode
14. How to use static methods of classes in PHP_______________________________;
Outside the class, use: class name followed by double colon, and then Following is the method name, similar to classname::staticFucntion(). Since the static method does not belong to an object, but to the entire class, it must be called with the class name.
2.
1. What is the reason for the following error: mysql server not go away? (This is probably like this)
It should be mysql has gone away, right?
Usually it is caused by the value set by max_allowed_packet is too small. max_allowed_packet is used to control the packet size of the buffer, sometimes when importing data , if this value is too small, it will easily cause insufficient buffer capacity. The problem can be solved by setting this value in my.ini or my.cnf to a larger value.
Another possibility is that the singleton mode is used when connecting to the database. The database is operated multiple times but the same connection is used. Since mysql processes each thread in queue mode, the current operation has not been completed and the interval is less than This problem is prone to occur when the value set by wait_timeout is high. The solution is to set the value of wait_timeout larger.
2. The difference between static tables and dynamic tables in mysql, and the difference between MyISAM and InnoDB.
Static tables are static when a table does not use variable length fields such as varchar, blob, and text. On the other hand, if a table contains at least one variable-length field, or if a table is created with the ROW_FORMAT=DYNAMIC option, the table is a dynamic table.
The difference between myisam and innodb is that myisam does not support transaction processing, because it does not need to do commit operations, so the operation speed will be faster than innodb. innodb is better than myisam in terms of security because it supports transaction processing, insert, update, delete, and select. When the operation defaults to autocommit=0, each operation will be treated as a transaction and can be rolled back.If autocommit=1, it will automatically commit the transaction after each operation, which will cause the execution efficiency to be very slow, probably 10 times slower than myisam.
3, $a = 1; $b = & $a;
unset($a), is $b still 1, why?
unset($b), is $a still 1? Why?
are all equal to 1.
In PHP, reference assignment is different from pointer. It just points another variable name to a certain memory address. In this question: $b = &$a; just points the name $b to the memory address pointed to by the $a variable. When unset, only the pointer to this name is released, but the value in the memory is not released. On the other hand, unset($a) does not actually release the value in the memory immediately. It only releases the pointer of this name. This function will only release the value when the space occupied by the variable value exceeds 256 bytes. The memory is released, and the address will be released only when all variables pointing to the value (such as reference variables pointing to the value) have been destroyed.
3.
1. Write at least three functions, take the suffix of the file name, such as the file '/as/image/bc.jpg', and get jpg or .jpg.
function myGetExtName1( $path ){
//Get the last occurrence. The index position of this character
$begin = strrpos($path,'.');
//Get the entire string Length
$end = strlen($path);
//The result of intercepting the total length of the string from the index of the last . returns
return $begin?substr($path,$ begin,$end):'The file has no extension';
}
function myGetExtName2($path){
return preg_match_all('/.[^.]+/is',$path,$ m)?$m[0][count($m[0])-1]:'The file has no extension';
}
function myGetExtName3( $path ){
//Find the last The index position of an occurrence of . character and all characters following it are returned together
return strrchr($path,'.')?strrchr($path,'.'):'The file has no extension';
}
2. Write a function to calculate the relative paths of two files, such as $a = '/a/b/c/d/e.php'; $b = '/a/b/12/34/ c.php'; Calculate the phase path of $b relative to $a.
$a = '/a/b/c/d/e.php';
$b = '/a/b/12/34/c.php';
//Ask for $b Relative path relative to $a
function getRelativelyPath($a,$b){
//Split into an array
$a = explode('/',$a);
$b = explode('/',$b);
$path = '';
//Reset the indexes of the two arrays
$c = array_values(array_diff($a,$b)) ;
$d = array_values(array_diff($b,$a));

//Remove the file name of a path
array_pop($c);
//Replace a Replace the directory name in the path with ..
foreach($c as c,$d);
//Splicing path
foreach($e as &$v)
$path .= $v.'/';
return rtrim($path,'/ ');
}
3. Use the binary method (also called the halving search method) to find an element. The object can be an ordered array.
//Binary method to find whether a certain value exists in an array
function binSearchWithArray($array,$searchValue){
global $time;
if(count($array)>=1) {
$mid = intval(count($array)/2);

echo 'th',$time++,'time
';

echo 'Current array: ';print_r($array);echo '
';


echo 'Find location index:',$mid,'
';

echo 'value :',$array[$mid],'

';

if($searchValue == $array[$mid]){
$time--;
return $searchValue.' was found, at the '.$time.'th time, the index is '.$mid.'
';

}
elseif($searchValue < ; $array[$mid]){
$array = array_slice($array,0,$mid);
return binSearchWithArray($array,$searchValue);
}
else{
$array = array_slice($array,$mid+1,count($array));
return binSearchWithArray($array,$searchValue);
}
}
return $searchValue.' Not Found ,50,60,199,35);
//The value to be found
$searchValue = 13;
//Sort the array, the key to dichotomy
sort($array);
echo 'The value to be found is:',$searchValue,'

';

echo binSearchWithArray($array,$searchValue);

These questions say It’s not difficult to be honest, but I still have to admit that I looked up the information for some questions, because there are many functions that I can’t even remember how to write without the help of an IDE. Even if I knew and understood some concepts before, I will gradually forget them if I haven’t touched them for a long time, such as Pass that by reference.
During the interview, you are asked to write with a pen. I believe that few people can write all these things with a pen in a short time, especially those who write code later. They need to revise repeatedly because you are thinking in the process. There will definitely be some loopholes in the logic. You need to execute the code to understand what went wrong. Writing it down with a pen is really nonsense. Even if I wrote it on a computer, it still took me 2 or 3 hours to write some of the following codes.
The written test questions during the interview are really open to question. I believe I am not the only one who feels this way, right? The last time I went to Tencent for an interview, I was stumped by the written test questions. When I got there, my mind was blank. After I returned home, I slowly recalled the questions and found that they could all be written.
Everyone, take a look at my answers and see if there are any omissions or errors. I don’t think it’s worth taking these tests, I just think it’s inappropriate to use them as written test questions during interviews. I hope that all of you who have participated in interviews with others in various companies can refer to my opinions and change to a more reasonable assessment method.

Original address: http://bbs.csdn.net/topics/340149214
The above introduces the interview questions said to be from Sina Leju, my answers, and some suggestions for the written test questions, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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