Summary of interview questions for about two weeks in early April!
The difference between echo(), print(), print_r()
echo() is a language structure, no return value
The function of print() is basically the same as echo(), and it is also a language structure. The difference is that print has a return value, and always returns 1
print_r is a recursive print for output array objects
2. What is the difference between the statement include and require? To avoid including the same file multiple times, can (?) statements be used instead of them?
Include generates a warning when an exception occurs and requires a fatal error
include_once()/require_once()
3. How to modify the survival time of the session
// save for a day
$lifetime = 24 * 3600;
session_set_cookie_params($lifetime);
session_start();
4. Write the sql of the ten people with the most number of posts, use the following table: members(id, username, posts, pass, email)
Select name from members order by posts,id desc limit 0,10
5. Please explain the difference between the passed value and the transmission reference in PHP. When to pass the value and when to pass the reference?
Pass values: Variables always pass value assignment by default. When the value of a variable is assigned to another variable, changing the value of one of the variables will not affect the other variable.
Passing Reference: Changing a new variable will affect the original variable, and vice versa.
When transmitting the value, the value must be copied. For large-scale strings and objects, there is a certain performance loss, and the transmission reference does not need to copy the value, which is beneficial to the performance improvement.
6. What is the function of the error_reporting function in php?
Set the error reporting level when the script is run
7. Please write a function to verify whether the format of the email is correct
preg_match(“/^(?:w+.?)*w+@(?:w+.?)*w+$/”, $email);
8. What is the function of the JS form pop-up dialog box? What is the input focus function?
alert(), prompt(), confirm()
focus()
9. What is the steering function of js? How to introduce an external js file?
window.location.href
<srcipt type=”text/javascript” src=”*.js”<</srcipt>
10. Please use jQuery to get the element with the class in the following documents as GB2
$(.GB2)
11. What is the difference between mysql_fetch_row() and mysql_fetch_array()?
mysql_fetch_row() gets a row from the result set as an enumeration array
mysql_fetch_array() takes a row from the result set as an associative array, or a number array, or both
12. Which of the following functions can open a file to read and write the file?
(a) fget()
(b)file_open()
(C) fopen()
(D) open_file()
(c)
13. Which of the following options does not add John to the users array?
(a)$users[]=john;
(b)array_add($users,john);
(C) array_push($users,john);
(d)$users ||=john;
(B) and (D) are not added to
14. How much will the following program output?
<?php
$num = 10;
function multiply() {
$num = $num * 10;
}
multiply();
echo $num;
?>
10
15. Use php to write a simple query, find out all the contents named “Zhang San” and print them out
table name user
name tel content date
Zhang San 13333663366 College graduate 2006-10-11
Zhang San 13612312331 College graduate 2006-10-15
Zhang Si 021-55665566 College graduate 2006-10-15
Please complete the code according to the above questions:
<?php
$mysql_db = mysql_connect(“localhost”, “root”, “pass”);
@mysql_select_db(“db”, $mysql_db);
$sql = “Select name, tel, content, date from user where name=Zhang San”;
$result = mysql_query($sql);
if ($row = mysql_fetch_array($result)) {
echo $row[‘Name’].$row[‘Tel’].$row[‘Content’].$row[‘Date’];
}
?>
16. How to use the following class and explain what the following means?
<?php
class test {
function get_test($num) {
$num = md5(md5($num).”en”);
return $num;
}
}
$test = new test();
$num = 1;
$test->get_test($num);
?>
17. Write out the format of SQL statements: insert, update, delete
table name user
name tel content date
Zhang San 13333663366 College graduate 2006-10-11
Zhang San 13612312331 Bachelor’s 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 High school graduation 2007-05-06) Please use sql statement to add to the table
(b) Please use the sql statement to update Zhang San’s time to the current system time
(C) Please write all records named Zhang Si deleted
(a)
INSERT INTO USER(name,tel,content,Date) values(Xiao Wang,13254748547,Graduated from high school,2007-05-06)
(b)
update user set date=date_format(now(),%y-%m-%d) where name=Zhang San
(c)
Delete from user where name=Zhang Si
18. Please write the meaning of the data type (int char varchar datetime text); what is the difference between char and varchar
int number type, char fixed length string, varchar variable length string, datetime date/time type, combination of date and time, text string of text
The length of the char is fixed to the length declared when the table is created, and when saving the char value, fill the space on their right to reach the specified length. VARCHAR is a variable-length string, and the VARCHAR value is not filled when it is saved.
19. MySQL self-increment type (usually the table ID field) must be set to (?) field
primary key
20. Write the output result of the following program
<?php
$b = 201;
$c = 40;
$a = $b>$c?4:5;
echo $a;
?>
4
21. Is there a function to detect whether a variable is set? Is the function that is empty?
isset()
empty()
22. What is the function to obtain the total number of query results?
mysql_num_rows($result);
23. $arr = array(James,tom,symfony);
(1) Please print out the value of the first element
(2) Please use the value of the array,Separate and merge into string output
(1)
<?php
$arr = array(James,tom,symfony);
echo $arr[0];
?>
(2)
<?php
$arr = array(James,tom,symfony);
echo implode(,,$arr);
?>
24. $a =abcdef; please take out the value of $a and print out the first letter
<?php
$a =abcdef;
echo $a{0};
?>
25. Please write out the PHP5 permission control modifier
Publicly Protected (protected) private (private)
26. Please write the constructor and destructor of php5
_construct
_destruct
27. Have you used version control software? What is the name of the version control software you use?
Used, such as SVN, Git, etc.
28. Have you ever used a template engine? If there is the name you use as the template engine?
Used, such as Smarty, Ease template, etc.
29. For websites with large traffic, what kind of method do you use to solve the problem of traffic?
1. Use flow analysis statistical software;
2. Confirm whether the server hardware is enough to support the current traffic;
3. Optimize database access;
4. External hotlinks are prohibited;
5. Control the download of large files;
6. Use different hosts to divert the main traffic;
30. Talk about your understanding of MVC?
The goal of MVC is to separate business logic from the consideration of the user interface. In MVC, the model (model) represents information (data) and business rules; view (view) contains user interface elements, such as text, forms, etc.; controller (controller) manages the communication in the model and view.
31. Have you ever used Eclipse as a PHP development IDE? If yes, please name the shortcut keys and corresponding functions of at least three debugs
32. Write a function, as efficiently as possible, iterate through all the subfolders in the folder ‘home’, and return an array of subfolder names
<?php
/**
* Traverse the directory, the result is stored in the array, support php4 and above, after php5 can use the scandir() function instead of the while loop
* @param string $dir
* @return array
*/
function my_scandir($dir) {
$files = array();
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false) {
if ($file != “..” && $file != “.”) {
if (is_dir($dir . “/” . $file)) {
$files[$file]= my_scandir($dir . “/” . $file);
} else {
$files[]= $file;
}
}
}
closedir($handle);
return $files;
}
}
function my_scandir1($dir){
$files = array();
$dir_list = scandir($dir);
foreach ($dir_list as $file) {
if ($file != “..” && $file != “.”) {
if (is_dir($dir . “/” . $file)) {
$files[$file]= my_scandir1($dir . “/” . $file);
} else {
$files[]= $file;
}
}
}
return $files;
}
$result = my_scandir(E:\php\home);
// $result1 = my_scandir1(E:\php\home);
print_r($result);
?>
33. Describe the meaning of the following code snippet in detail (Note: The expected cannot be achieved, this is the original code)
<?php
$text =Come and join us! Corporate Socialization Discussion Group;
// preg_replace(/(^|[\s\.\,\:\;]+)!([A-Za-z0-9\x80-\xff]{1,64})/E,\\1!.common_link($id,\\2)”, $text);
?>
Execute a regular expression search and replacement to remove the punctuation in $text
34. Write code as required
(1) Declare a cat object, the object has a common property: name; two behaviors: walk(), talk()
(2) Declare a MyCat object and inherit the cat object
(3) Mycat has a public property: color
(4) Instantiate a Mycat object and assign the color attribute toblankk
(5) Execute the Talk method of mycat and print out the color attribute value of the current mycat object
<?php
// (1)
class cat {
public $name;
function walk() {
}
function Talk() {
}
}
// (2)(3)
class mycat extends cat {
public $color;
}
// (4)(5)
$mycat = new mycat();
$mycat->color =black;
$mycat->talk();
print($mycat->color);
?>
1. What is BOM and what are the hazards?
BOM (Byte Order Mark) is the standard mark used to identify the encoding in the UTF encoding scheme
Due to the existence of BOM, PHP will mistake the text content has been output, so it will affect the page rendering
2. If the HTML webpage code written by the front-end engineer is GB2312, and the database and PHP file are encoded as UTF-8, how to quickly solve this problem?
Quick solution: PHP file to output header: header(“content-type:text/html;charset=GB2312”), and the php file itself needs to be converted to GB2312
mysql_query(“set names GBK”);
Complete solution: convert html web pages to utf-8, all unified to utf-8
3. <!– will[img]http://www.leshisz.com/themes/default/images/index/ad/ad-stay-tuned.png[/img]Replace with <img alt=”stay tuned” src=”http://www.leshisz.com/themes/default/images/index/ad/ad-stay-tuned.png” height=”288″ width=”500″></img>, UBB code –>
<?php
$str =[img]http://www.leshisz.com/themes/default/images/index/ad/ad-stay-tuned.png[/img];
//<img alt=”stay tuned” src=”http://www.leshisz.com/themes/default/images/index/ad/ad-stay-tuned.png” height=”288″ width=”500″></img>
$img = str_replace([img],<img alt=”stay tuned” src=”, $str);
$img = str_replace([/img],” height=”288″ width=”500″></img>, $img);
echo $img;
?>
4, mysql performance detection, what to add before the sql statement?
If the keyword explain is placed before the SELECT statement, MySQL will explain how it handles the SELECT, providing the order of how the table is joined.
5. Different users may have the same IP, and it is necessary to count the number of different IPs, and arrange them in descending order
table name user
id name tel ip date
1 Zhang San 13333663366 01.33.22.33 2006-10-11
2 Zhang San 13612312331 03.22.33.33 2006-10-15
3 Zhang Si 021-55665566 01.33.22.33 2006-10-15
Select count(ip) as count from user group by id order by count desc
6. Print out the $_POST and $_GET of the current form
<form method=”post” action=”2.php?s=1&a=2″>
<input type=”hidden” name=”var[]” value=”aa”>
<input type=”hidden” name=”var[]” value=”bb”>
<input type=”checkbox” name=”checkbox” value=”cc”>
<input type=”submit” name=”submit” value=”submit”>
</form>
$_post = array (
var => array (
0 =>a,
1 =>bb
)
submit =>Submit
)
$_get = array (
s => 1,
a => 2
)
(1) Basic questions
1. Write the program to output the result in the browser:
<?php
$str1=null;
$str2=false;
echo $str1==$str2?Equal:Not equal;
$str3=;
$str4=0;
echo $str3==$str4?Equal:Not equal;
$str5=0;
$str6=0;
echo $str5===$str6?Equal:Not equal;
?>
equality equality not equal
2. Write the program to output the result in the browser:
<?php
$a1=null;
$a2=false;
$a3=0;
$a4=;
$a5=0;
$a6=null;
$a7=array();
$a8=array(array());
echo empty($a1)?true:false;echo</br>;
echo empty($a2)?true:false;echo</br>;
echo empty($a3)?true:false;echo</br>;
echo empty($a4)?true:false;echo</br>;
echo empty($a5)?true:false;echo</br>;
echo empty($a6)?true:false;echo</br>;
echo empty($a7)?true:false;echo</br>;
echo empty($a8)?true:false;
?>
true
true
true
true
true
false
true
false
3. Write the program to output the result in the browser:
<?php
$str=”a”;
$$str=”net”;
$$str.=”work”;
$b=&$a;
unset($b);
$b=”hello wolrd”;
echo $a;
echo “</br>”;
echo $b;
?>
network
hello wolrd
4. Write the program to output the result in the browser:
<?php
$a=99;
$b=100;
$c=10;
++$a>$b–?$c++:$c++=$b;
echo $a.”</br>”.$b.”</br>”.$c;
?>
100
99
109
5. Use php to print out the time format of the previous day is 2004-4-8 11:11:11
<?php
print_r(date(Y-N-J H:I:S), strtotime(-1 day));
?>
6. Write the code to display the client IP and the server IP in PHP
<?php
echo $_server[‘REMOTE_ADDR’];
echo $_server[‘SERVER_ADDR’];
?>
7. Please list several ways to pass values in PHP pages
get post cookie
8. Exchange the values of the existing two variables directly without new variables
<?php
$a = 1;
$b = 2;
// Assign the value in the array to some variables
list($b, $a) = array($a, $b);
?>
10. List several commonly used PHP frameworks
Yii, ThinkPHP, Zend Framework, CakePHP
(2) Algorithm and program problems
1. How to implement string flip
<?php
$a =abcde;
$b =;
for ($i=strlen($a)-1;$i>=0;$i–) {
$b .= $a{$i};
}
// or
$c = strrev($a);
?>
2. Writing Bubble Sorting Algorithm
<?php
$arr = array(45,56,67,32,33,23,37,455,223,223,23);
for ($i=1;$i<count($arr);$i++) {
for ($j=count($arr)-1;$j>=$i;$j–) {
if ($arr[$j]<$arr[$j-1]) {
$temp = $arr[$j-1];
$arr[$j-1]= $arr[$j];
$arr[$j]= $temp;
}
}
}
?>
4. There is a table menu(parent, clildren, url), please use the recursive method to write a tree menu, and list all the menus
&lt;?php
// parent is null, which means no parent, it is a level menu, and Clidren is its own ID
$menu = array(
0 =&gt; array(null,1, url1),
1 =&gt; array(null, 2, url2),
2 =&gt; array(1,3, url3),
3 =&gt; array(1,4, url4),
4 =&gt; array(2,5, url5),
5 =&gt; array(1,6, url6),
6 =&gt; array(4,7, url7),
7 =&gt; array(5,8,url8)
);
function menu($menu) {
$menu1 = array();
$menu2 = array();
// first level menu
foreach ($menu as $k =&gt; $v) {
if ($v[0]== null) {
$menu1[$v[1]] = $v;
unset($menu[$k]);
}
}
// secondary menu
foreach ($menu as $k =&gt; $v) {
foreach ($menu1 as $k1 =&gt; $v1) {
if ($v[0]== $v1[1]) {
$menu1[$v1[1]]['clildren'][$v[1]] = $v;
unset($menu[$k]);
}
}
}
// three-level menu
foreach ($menu as $k =&gt; $v) {
foreach ($menu1 as $k1 =&gt; $v1) {
if ($v1['clildren']) {
foreach ($v1['clildren']as $k2 =&gt; $v2) {
if ($v[0]== $v2[1]) {
$menu1[$v1[1]]['clildren'][$v2[1]]['clildren'][$v[1]] = $v;
unset($menu[$k]);
}
}
}
}
}
return $menu1;
}
$menu3 = menu($menu);
print_r($menu3);
?&gt;
(3) Comprehensive questions and answers
3. Talk about transaction processing
What is a business? The so-called transaction (transaction) is actually an operating unit, and all operations in this unit either execute or fail. If all operations are successful, the transaction commits a commit. Even if an operation fails, the transaction will roll back and all the affected data will be restored to its previous state.
4. What is the difference between GET and POST for form submission? How to implement local updates on the client side to interact with the server to complete the interaction?
The GET method is the default method for the form to submit data, which passes the user’s data through the URL request. The amount of data transmitted by the GET method is very small, generally limited to about 2KB, but its execution efficiency is higher than that of the POST method. Since the data transmitted using the GET method is transparent to the user, there may be some security problems. The POST method uses the HTTP POST mechanism to place the data in the form in the HTML header (Header) and pass it to the server side. Different from the GET method, the data passed by the POST method is invisible to the user, and the amount of data passed by the POST method is also relatively large.
ajax
7. What is the principle of SQL injection and how to prevent SQL injection?
SQL injection means that the attacker can insert the SQL command into the web form submission or enter the query string of the domain name or page request, and finally achieve the purpose of letting the background database execute the malicious SQL command, and obtain the data that some attackers want to know according to the result returned by the program.
Prevention method:
Programmers strengthen their own technical level and use fixed development standards;
Check the legitimacy of the data before submitting to the server;
Close the client submission information;
Replace or delete sensitive characters and strings;
The error message is not returned to the user;
Data sensitive information is unconventional and encrypted to prevent information leakage;
Strengthen database inspection, web server log check;
Sql queries are established without string connections, but SQL variables are used, because the variables are not executable scripts;
8. There are the following two table structures, the user table:user, user group table:group:
// The table name and field name cannot be added with single quotation marks, and the group cannot be used, so the field group is changed to groupId, and the table group is changed to groups.
create table user(
id int(11) not null primary key auto_increment,
username varchar(50) default null,
age int(11) default null,
level int(11) default null,
groupId int(11) default null
) engine=myisam default charset=utf8;
create table groups(
groupId int(11) not null auto_increment,
groupname varchar(50) default null,
grouplevel int(11) default null,
primary key(groupid)
) engine=myisam default charset=utf8;
Writing SQL query statement query:
(1) The user ID whose age is less than 20-50, surnamed “Zhang”, and the user ID whose level is less than 5; in descending order
Select id from user where (age between 20 and 50) and username likeZhang%and level<5 order by age,id desc
(2) Take out all user names with a user group whose name is “Technical Department” and the user group level between 2-10
Select username from user as u left outer join groups as g on u.groupid=g.groupid where g.groupname=Technology Departmentand (g.grouplevel between 2 and 10) and u.age>25
(3) The number of members above the age range 1-10, 11-20, 21-30, and 31 belong to the number of members who belong to the “Technical Department” of the user group, and display it according to the corresponding number of the range.
select count(id) from user as u
Left outer joins as g on u.groupid=g.groupid
where (g.groupname=Technology Department) and (u.age between 1 and 10)
So repeat and execute it 3 times.
(4) Socket operation
1. List several commonly used operation functions of PHP Socket communication, what are the functions and how to judge the abnormality of each operation?
getProtoByName() Get the agreement number related to the agreement name
socket_create() creates a socket (communication node)
socket_bind() binds the name of the socket
2. Write a simple socket request program, the specified IP is: 192.168.0.1, the specified port is: 9501, the sending content: 12345, the protocol is TCP
<?php
//Make sure that it does not timeout when connecting to the client
set_time_limit(0);
$ip =192.168.0.1;
$port = 9501;
tiveting
+-----------------------------
* @socket communications whole process
+-----------------------------
* @socket_create
* @socket_bind
* @socket_listen
* @socket_accept
* @socket_read
* @socket_write
* @socket_close
+------------------------------
*/
/*--------------- The following operations are all in the manual ------------------*/
if(($sock = socket_create(af_inet,sock_stream,sol_tcp)) < 0) {
The reason why echo "socket_create() fails is: ".socket_strError($sock)."\n";
}
if(($ret = socket_bind($sock, $ip, $port)) < 0) {
The reason why echo "socket_bind() fails is: ".socket_strError($ret)."\n";
}
if(($ret = socket_listen($sock,4)) < 0) {
The reason why echo "socket_listen() fails is: ".socket_strError($ret)."\n";
}
$count = 0;
do {
if (($msgsock = socket_accept($sock)) < 0) { echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . "\n"; break; } else { //Send to the client $MSG = "Test success!\n"; socket_write($msgsock, $msg, strlen($msg)); echo "The test is successful\n"; $buf = socket_read($msgsock,8192); $TALKBACK = "Received: $BUF\n"; echo $TalkBack; if(++$count >= 5){
break;
};
}
//echo $buf;
socket_close($msgsock);
} while (true);
socket_close($sock);
?>
<?php
error_reporting(e_all);
set_time_limit(0);
echo "
<h2>tcp/ip connection</h2>
\n";
$port = 9501;
$ip = "192.168.0.1";
tiveting
+-----------------------------
* @Socket connect the whole process
+-----------------------------
* @socket_create
* @socket_connect
* @socket_write
* @socket_read
* @socket_close
+------------------------------
*/
$socket = socket_create(af_inet, sock_stream, sol_tcp);
if ($socket < 0) {
echo "socket_create() failed: reason: " . Socket_strError($socket) . "\n";
}else {
echo "OK.\n";
}
echo "trying to connect$ipinterface$port...\n";
$result = socket_connect($socket, $ip, $port);
if ($result < 0) {
echo "socket_connect() failed.\nreason: ($result)" . Socket_strError($result) . "\n";
}else {
echo "Connect OK\n";
}
$in = "12345\r\n";
$out =;
if(!socket_write($socket, $in, strlen($in))) {
echo "socket_write() failed: reason: " . Socket_strError($socket) . "\n";
}else {
echo "Send to server information successfully!\n";
echo "The content sent is: <font color=red>$in</font>
";
}
while($out = socket_read($socket, 8192)) {
echo "Received the server to send back the message successfully!\n";
echo "Accepted content is:",$out;
}
echo "Close Socket...\n";
socket_close($socket);
echo "Close OK\n";
?>
1. Use your own way to write a calculator, including functions +-*/, etc., play according to your own technical level, the higher the code quality, the better
<?php
// The first parameter is the calculation symbol, and the second and third parameters are the values to be calculated
function calculation($symbol, $v1, $v2) {
if (is_numeric($v1) && is_numeric($v2)) {
switch ($symbol) {
case+:
return $v1+$v2;
break;
case-:
return $v1-$v2;
break;
case;:
return $v1*$v2;
break;
case/ / *:
return $v1/$v2;
break;
default:
returnComputation symbols only support +-*/, others are not supported;
break;
}
} else {
returnThe first parameter is the calculation symbol, the second and third parameters are the values to be calculated, and must be numbers;
}
}
echo Calculate(-, 6, 3);
?>
2. Briefly tell the story of MySQL advanced technology and in practice
3. Talk about the use of symbols such as symbols in program coding, the more detailed the better the better
.: connection string
,: spacer symbols in array
-: Subtraction operator
@: error suppression operator
&: && is a logical operator, representing and
–: Self-decrement operator (when the operator is behind the variable, first return the value of the variable and then decrement it; when the operator is in front of the variable, decrement first and then return the variable value)
++: Self-added operator (when the operator is behind the variable, first return the variable value and then add it;
^: XOR operator
$: variable prefix symbol
4. Talk about your understanding of object-oriented
“Object-Oriented” decomposes the transactions that make up the problem into each object. The purpose of establishing the object is not to complete a step, but to describe the behavior of a transaction in the entire problem-solving step.
6. Program to realize the order of the letters of a string that reverses
<?php
$v1 =abcde;
$v2 =;
for ($i=strlen($v1)-1; $i>=0; $i--) {
$v2 .= $v1{$i};
}
echo $v2;
?>
7. Write out at least 5 ways to optimize mysql database
Optimize queries, such as using indexes, using connection queries instead of subqueries
Optimize the database structure, such as sub-table, adding intermediate tables, adding redundant fields, parsing tables, checking tables, optimizing tables
Optimize the speed of insert records, such as disable index before inserting records, insert multiple records in one insert statement
Optimize the hardware configuration of MySQL server, such as increasing memory, disk number, and improving disk read and write speed
Optimize MySQL server parameter configuration
1. Use js syntax (non jquery syntax) to write the equivalent statement of the following statement ($ represents $ in jQuery)
<script>
$.each([0, 1, 2], function(i, n){ alert(i); });
var a = new array(0, 1, 2);
for (var i = 0; i < a.length; i++) {
alert(i);
}
</script>
2. What is the function of the following sentences? ($ stands for $ in jQuery)
2.1
<script>
var a = 2;
var b = 3;
var fun = $.extend({
min: function(a, b){ return a < b ? a : b; },
max:function(a, b){ return a > b ? a : b; }
});
// Merge one object, {min:2, max:3}, generally need two objects to execute the merge
</script>
2.2
<script>
$(document).ready(function(){
$("tr").hover(function(){
$(this).addClass("over");
}, function(){
$(this).addClass("out");
})
})
//When the mouse is moved to tr, add a class over to t, and when move away, add class out to tr
</script>
3. What are the elements in the industry? What are the block-level elements?
Inline elements:
a – anchor point, br – line break, em – emphasize, img – image, input – input box, span – define the block, textarea – multi-line text input box, sub – subscript, sup – Superscript, label – table label, etc.
Block-level elements:
H1 – Big Title, H2 – Subtitle, H3 – Level 3 Title, H4 – Level 4 Title, H5 – Level 5 Title, H6 – Level 6 Title, DIV – Common Block Level Content, Also CSS Layout’s main tag, dl – defining list, dt – defining the items in the list, UL – unsorted list, ol – sorted list, li – defining list items, table – table, tbody – Table body (body text), td – standard cells in the table, thead – table header, tfoot – table footer (footnote or table notes), tr – rows in the table, etc.
4. Describe the objects in javascript according to your understanding
Everything in JavaScript is an object: string, value, array, function…
Also, JavaScript allows custom objects.
5. List the IE6 hack you encountered in your work and talk about solutions
Ultimate Method: Conditional Notes <!–[if lte IE 6]><html><![endif]–>
CSS selectors distinguish, IE6 does not support subselectors, first use general declaration selectors for IE6, and then use sub selectors for IE7+ and other browsers
IE6 is not supported but supported by other browsers! Important
When the element floats, IE6 will double the calculation of the margin value of the floating direction incorrectly, so try to avoid the concurrent use of float and margin.
:hover (except href) is not supported in IE6, it is best not to use :hover to implement important functions, and directly use js events
For the problem of PNG translucent picture, it is recommended to use png-8 as much as possible. If png-24 or png-32 is used, it needs to be implemented through js
6. What are the methods of CSS? What is the difference between link and @import?
Use link tags
Use style attribute
Use style tags
Introduce with @import
Difference:
link belongs to the xhtml tag, and @import is a way provided by css
The difference in the loading order, when a page is loaded, the css referenced by the link will be loaded at the same time, and the css referenced by @import will wait until the page is all downloaded before being loaded
The difference in compatibility, @import is not supported in some older versions of browsers (IE5-)
The difference when using DOM to control the style, when using JavaScript to control the DOM to change the style, you can only use the LINK tag, because @import is not controlled by the DOM.
7. What are the ways to remove floating and what are the applicable situations?
Use empty labels to clear floats
Use the overflow property
Use After pseudo-object to clear floating
8. Are you concerned about HTML5 and CSS3? Please briefly talk about what you know about them, or write a few lines of code to explain
HTML5 will be the new standard for HTML, XHTML, and HTML DOM.
The last version of HTML was born in 1999, and the web world has undergone dramatic changes since then.
HTML5 is still in the process, however, most modern browsers already have some HTML5 support.
CSS3 is the latest CSS standard.
W3C is still developing the CSS3 specification. Modern browsers have implemented quite a few CSS3 properties.
9. If you were asked to make a large-scale website with a large number of traffic, how would you manage all CSS files, JS files and pictures?
The establishment of front-end development specifications, such as encoding mode, CSS reset/global file, background image using aggregation, etc.;
The page is marked, such as the beginning and end of the module;
A single functional module is marked with basic information such as the author and module name;
The name of a single functional module, html/js/css/image, etc. should be uniformly named;
Add a status value after the front-end file URL, such as MD5 value, etc., corresponding to a specific version;
Specify the picture size, do not use size scaling, etc.;
Optimize the picture, while maintaining a certain quality, such as ysmush.it (lossless compression), etc.;
Compress and merge files in the production environment;
10. Have you ever done front-end development of ASP.NET projects? What is your role in the project?
11. There is a website with the following sections:
Home of Webmasters|Website Operation|Design Online|Network Programming|Alliance Information|Server
The mouse is moved to Design Online and the following two-level menu is displayed:
Web Design|Web Standard|Video Processing|Design Activities
The mouse is moved to the network programming and the following second-level menu is also displayed
PHP programming|.NET programming|XML programming
Mouse left Design online or network programming, the secondary menu will automatically hide
Using JSON or XML data output by the server (the data is constructed by itself), use JavaScript to output the data to the layer <div id=”nav”></div>. (The method of requesting the server-side data is as follows ajaxread; the server-side address is: “/ajax.aspx?type=nav”)
function ajaxread(src,fun){
//The method can read the relevant JSON or XML data according to the request address SRC, and then execute the callback function FUN
}
Please construct the JSON or XML data of the menu
<?php
$nav = array(
Webmaster’s Home=> array(),
website operation=> array(),
Design Online=> array(
Web Design=> array(),
web standard=> array(),
video processing=> array(),
Design Activities=> array()
,
network programming=> array(
php programming=> array(),
.NET programming=> array(),
xml programming=> array()
,
Alliance Information=> array(),
Server=> array()
);
print_r($nav);
$code = json_encode($nav);
echo preg_replace(“#\\\u([0-9a-f]+)#IE”, “iconv(UCS-2,UTF-8, pack(h4,\\1))”, $code);
?>
<script>
var json = {“Home of the webmaster”:[], “Website Operations”:[],”Design Online”:{“Web Design”:[], “Web Standard”:[], “video processing”:[], “Design Activity”:[]},”Network Programming”:{“PHP programming”:[],”.net programming”:[],”XML programming”:[]}, “Alliance Information”:[],”server”:[]};
var nav = eval(json);
$(nav).each(function(i,n) {
var val = nav[i];
if (typeof (val.summary) == “object”) {
$(val.summary).each(function(i,n) {
// secondary menu
});
} else {
// first level menu
}
});
</script>
Please improve the callback function FUN
// Iterate over the json data, build the UL menu, and then insert (append) the div
3. There is a web page address, such as Honghe company homepage: http://www.sc66666.com/index.html, how to get its content?
<?php
$url = “http://www.sc66666.com/index.html”;
$contents = file_get_contents($url);
echo $contents;
?>
4. Describe the garbage collection algorithm of PHP5.2 and PHP5.3 respectively, and compare its advantages and disadvantages
Garbage collection algorithm of PHP5.2 – Reference Counting, Chinese translation as “reference counting”, its thinking is intuitive and concise, and it is easy to cause internal leakage
Garbage Collection Algorithm for PHP5.3 – Concurrent Cycle Collection in Reference Counted Systems, in scenarios where cumulative memory leaks may be triggered, PHP5.2 has a continuous cumulative memory leak, while PHP5 .3 can always control the memory leak below a threshold (related to the size of the root buffer), but the performance of its garbage collection mechanism will be lower.