PHP face test for large companies

Source: Internet
Author: User
Tags create directory php language smarty template

1. Can I use seesion after I disable cookies?

2. What functions do you use to crawl remote images locally?

4. How much do you think LUnix is faster than win when you are pv10w in the same configuration?

5. What is the maximum capacity of the post and get transfers, respectively?

6. Write a function with a minimum of code that asks for the maximum value of 3.

Attached answer (not guaranteed to be the correct solution)

1. Cannot
2 Fsockopen

4 (same as in the case of no optimization)
5 2mb,1024b
6 function ($a, $b, $c) {
Return $a > $b? ($a > $c? $a: $c): ($b > $c? $b: $c);
}

———————————————————————————–

PHP face test for large companies

2. Ask for the difference of two dates, for example, 2007-2-5 ~ 2007-3-6 Date Differential
$begin =strtotime (' 2007-2-5′);
$end =strtotime (' 2007-3-6′);
Echo ($end-$begin)/(24*3600);

3. Write a function that implements the following functions:
The string "Open_door" is converted 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. Required to write a program, to achieve the following array $arr1 conversion to the group $ARR2:
$arr 1 = array (the
' 0′=> array (' FID ' = 1, ' tid ' = + 1, ' name ' = ' Nam ') e1′),
' 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′=> ar Ray (' FID ' = 3, ' tid ' = + 9, ' name ' = ' name5′ ')
);
$arr 2 = Array (
' 0′=> Array (the
' 0′=> array (' tid ' = = 1, ' name ' = ' name1′ '),
' 1′=> Array (' Tid ' = 2, ' name ' = ' name2′ ',
' 2′=> array (' tid ' = + 5, ' name ' = ' name3′ '),
' 3′=> array (' Tid ' = 7, ' name ' = ' name4′ '),
' 1′=> array (
' 0′=> array (' tid ' = + 9, ' name ' = ' name5′ '));

<?php
$arr 1 = 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);
}
$arr 2=changearraystyle ($arr 1);
echo "<pre>";
Var_dump ($arr 2);
?>

5. Please briefly describe the paradigm and application of database design.
The general 3rd paradigm is sufficient for the optimization of the table structure, which avoids the complexity of the application and avoids the system inefficiency caused by the SQL statement being too large.
ANSWER:
The first paradigm: if each attribute of the relationship pattern R is non-decomposed, then it belongs to the first paradigm.
The second paradigm: if R belongs to the first paradigm, and all non-code attributes are fully functional dependent on the code attribute, then the second paradigm.
The third paradigm: if R belongs to the second paradigm, and none of the non-code attributes is a transfer function dependent on the candidate code, then it belongs to the third paradigm.

6. The ID in a table has multiple records, the records of all the IDs are detected, and the number of records is displayed, and the SQL statements and views, stored procedures are implemented separately.
Stored procedures:
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 table has a B C three column, implemented with SQL statement: When column A is greater than column B Select column B otherwise select column B, when column B is greater than column C, select column C otherwise.
Select
Case
When First_name>middle_name Then
Case if First_name>last_name then first_name
else Last_Name End
Else
Case if Middle_name>last_name then Middle_name else last_name
End
End as name
From member

8 Please briefly describe how the SQL statement is optimized to perform efficiently in the project.
SQL optimization is used for birds, so it is better to index directly.

9 If the template is using the Smarty template. How to display an array named $data with the section statement. Like what:
$data = Array (
[0] = = Array ([id]=8 [name]= ' name1′)
[1] = = Array ([id]=10 [name]= ' name2′)
[2] = = Array ([id]=15 [name]= ' name3′)
......
)
Write the code on the template page? What if I use a foreach statement to display it again?
{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 the files and subfolders under a folder. (Directory operations)
<?php
$d = Dir (dirname (__file__));
echo "Handle:". $d->handle. "\\n";
echo "Path:". $d->path. "\\n";
while (false!== ($entry = $d->read ())) {
Echo $entry. "<br/>";
}
$d->close ();
?>
112 Table City table and province table. A table of relations between the city and the province, respectively.
City
ID City Provinceid
1 Guangzhou 1
2 Shenzhen 1
3 Huizhou 1
4 Changsha 2
5 Wuhan 3
.......... Guangzhou
Province:
ID Province
1 Guangdong
2 Hunan
3 Hubei
..........
(1) Write a SQL statement relationship two tables, implementation: show the basic information of the city.
(2) Display field: City ID, city name, province.
Such as:
ID (city ID) cityname (city name) privence (province)
。。。。。。。。。
。。。。。。。。。
(2) If you want to count the number of cities in each province, please use GROUP by query.
Display fields: Province ID, province name, number of cities.
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. According to your experience, please briefly describe the steps of software development. What are the drawbacks of rational Rose, PowerDesigner, Project, VSS, or CVS, and TestDirector used the following tools?
The company uses Dbdesigner and CVS, testing management tools with Mantis
13. Please describe the difference between the thread and the process of the operating system. List the software you used under Linux?

14. Use pseudo-language combined with data structure bubbling sorting 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 Face question Collection
1, the relationship between the COOKIE, the session and the difference, how many Web servers to share the session?
2. What is the difference between post and get in the HTTP protocol?
3, a section of PHP code, write out the results:
/**** This program ****/
$a = 0;
$b = 0;
if ($a =3) >0| | ($b =3) >0) {
$a + +;
$b + +;
echo $a;
Echo $b; The value of output B ($a =4, $b =1) $b =3 not executed
}
4. Reqiure include can contain files, what is the difference between them?

5. What is the principle of Web upload file in PHP, and how to limit the size of uploaded files?
Is_uploaded_file () and Move_uploaded_file ()

6, write a function, you can traverse all the files and folders under the folder.
7, 8, in the middle there are several Unix shell topics (like two), because do not understand, do not remember these topics
9, there is a document Mail.log, the content of a number of e-mail addresses, which use ' \\n ' to separate the e-mail address. Ask to pick out sina.com email addresses (including reading from files, filtering to print out).
Mail.log content is as follows:
[Email protected]
[Email protected]
[Email protected]
[Email protected]
[Email protected]

10, JS in the page forward and backward code (forward: History.forward (); =history.go (1); Back: History.back (); =history.go (-1);)
11, Window (a) with window.open () opened window (b), how to invoke window A from window B? A, B is just the window code, not the window name
12. Do you know Ajax? Have you used it? ......
13. What is MVC? Have you used it? What problems are encountered when using, how to solve them?
14. Write the message headers needed to access the http://www.sina.com.cn, hey, this is the super pig to think up. Md5_file ()

—————————————————————————–

—————————————————————————–

—————————————————————————–

Latest Sina PHP face Test (2009.3)

1. Echo count ("abc"); Output what?
Answer: 1

2. Write code that displays client IP and server IP in PHP
Answer: Client getenv (' REMOTE_ADDR ');
Server-side getenv (' server_addr '); gethostbyname ("www.baidu.com");

3. error_reporting (2047) what role?
Answer: Equivalent to error_reporting (' E_all '); All errors are output

4. How to implement PHP and JSP interaction?

The topic is a little vague, soap,xml_rpc,socket function,curl can achieve these, if it is a test of PHP and Java integration, PHP built-in this mechanism (if you test PHP and. NET integration, can also answer this), such as $foo = new Java (' Java.lang.System ');

5. Which parameters will be affected by opening the Safe_mode in php.ini? Say at least 6 of them.
Answer: When this module is opened, PHP will check that the owner of the current script is the same as the owner of the manipulated file, so it will affect the file operation class function and the program execution function (Programs execution Functions). These functions have. pathinfo,basename,fopen,system,exec,proc_open functions;

7. Please write a function to verify that the e-mail message is in the correct format (requires regular use)
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 the two-dimensional array.
Array_multisort ()

12. Write 5 different functions of your own to intercept the extension of a full-path file, allowing you to encapsulate functions already in the PHP library.

13. A group of monkeys in a circle, according to 1,2,...,n sequentially numbered. Then, starting from the 1th, Count to M., Kick It Out of the loop, start counting from behind it, Count to M., and Kick It out ... and so on, until the last monkey is left, the monkey is called the King. Requires programming to simulate this process, enter m, N, output the last king's number

7, optimize the MySQL database method.

(1). Database design Aspects, this is the responsibility of the DBA and architect, the design of a well-structured database, when necessary, to regularization (English is this: denormalize, Chinese translation into what I do not know), allow partial data redundancy, avoid join operation, to improve query efficiency
(2). System architecture design, the table hash, the huge amount of data scattered into a few different tables. Slow table, fast table only stay up-to-date data, slower table is a historical archive. Cluster, master server Read & write, from server read only, or n servers, each machine is master
(3). (1) and (2) Beyond PHP programmer requirements, will be better, will not matter. Check for fewer indexes
(4). Write efficient SQL statements to see if there are any inefficient SQL statements, such as the full connection of the generated Cartesian product, a large number of group by and order by, no limit, and so on. When necessary, the database logic is encapsulated in the DBMS side of the stored procedure. Cache query Results, Explain of each SQL statement
(5). All that is required is to fetch only the necessary data from the database, such as querying the number of comments for an article, select COUNT (*) ... where article_id =? Yes, don't select * ... where article_id =? Then Msql_num_rows.
Transfer only the necessary SQL statements, such as when modifying the article, if the user only modified the title, then ... set title =? where article_id =? Do not set content =? (large text)
(6). When necessary, use a different storage engine. For example, InnoDB can reduce deadlocks. Heap can increase query speed by an order of magnitude

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

<?php
$s = ' abc ';
if ($s ==0)
Echo ' is zero<br> ';
Else
Echo ' is not zero<br> ';
?>

Many people answer the wrong answer is that the output string "is not zero." In fact the correct answer should be the output string "is zero".

The reason is simple, because pHp is a weak type of language, it does not have a "must first define and then use" Mandatory requirements, the type of the variable is based on the type of assignment to change flexibly. This "flexibility" seems to be flexible, actually burying the wrong hidden dangers. Although $s = ' abc '; The statement defines the variable $s as a string type, but because the if ($s ==0) statement, the $s is compared to a numeric constant, so $s is implicitly converted to a numeric variable with a value of 0, so the result of $s ==0 comparison is true.

Those who make this type of mistake are generally from Java, C and other languages to the development of PHP programmers, because Java, C and other languages are strongly typed language, is not allowed to different types of variables and constants compared to each other, in this case will report a syntax error.

In fact, the PHP language developers do not pay attention to this kind of problem, in the PHP language there is a strict comparison of the operator "= = =", requires the comparison of the two sides must be of the same type, the above if ($s ==0) statement as if ($s ===0) will avoid the aforementioned error occurred.

———————————————————————————–

<?

$STR = "CD";

$ $str = "Hotdog"; $cd

$ $str. = "OK";

Echo $CD; Hotdogok

?>

————————————————————————————–
9, apache+mysql+php to achieve maximum load method
The optimization of the profile is mostly, and it is better to run with Linux than with Windows.

mkdir Create directory Touch Create folder Modify permissions chmod

51. Please write out the PHP5 permission control modifier (3 points)
Private protected public

13, for the large-volume website, what method do you use to solve the traffic problem? (4 points)
First, verify that the server hardware is sufficient to support current traffic
Second, optimize database access.
Third, prohibit the external hotlinking.
Four, control the download of large files.
V. Use different hosts to divert the main flow
VI, use traffic analysis statistics software.

The Htmlspecialchars () function converts some pre-defined characters to HTML entities.

The Htmlentities () function converts a character to an HTML entity. (Htmlentities () escapes more thoroughly. )
SQL injection is easy to avoid. As mentioned in chapter One, you must persist in filtering the input and escaping the output. ———

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

This page addresses the name of the current script.
Echo $_server[\php_self\]. " <br/> ";
URL address of the previous page linked to the current page:
Echo $_server[\http_referer\]. " <br/> ";

3. In HTTP 1.0, the meaning of status code 401 is (4), if you return the "File not found" prompt, you can use the header function,

Its statement is (5).
(4) Unauthorized (5) header ("http/1.0 404 Not Found"); ——— File not found
Header ("http/1.1 403 Forbidden"); ——— do not allow access

7. Install PHP in the Apache module, and in the file http.conf, the PHP module should be loaded dynamically with the statement (10).
Then use the statement (11) so that Apache will all files with the extension PHP as PHP script processing.
(Ten) LoadModule php5_module "C:/php/php5apache2.dll"
(one) AddType application/x-httpd-php-source. Phps
AddType application/x-httpd-php. php. php5. PhP4. php3. phtml

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

10. The argument 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 face test for large companies

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.