Home Backend Development PHP Tutorial 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.

Jul 29, 2016 am 08:56 AM
array nbsp path

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to Fix Activation Error Code 0xc004f069 in Windows Server How to Fix Activation Error Code 0xc004f069 in Windows Server Jul 22, 2023 am 09:49 AM

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using

See all articles