4. Write the assignment and explain how to run the PHP script (write two ways) at the command line and pass parameters to the PHP script.
5. What is the garbage collection mechanism of PHP?
6. Enables an object to be a foreach loop like an array, requiring that the property be private.
(Iterator mode of PHP5 implementation, write a class of implementation iterator interface)
7. Write a section of PHP code to ensure that multiple processes write to the same file at the same time successfully
8. Implementing a bidirectional queue in PHP
9. Use a regular expression to extract a specified property value for a specified label in a section of an identity language (HTML or XML) snippet (consider the irregular condition of the property value pair, such as case insensitive, a space between the property name value and the equal sign). Suppose you want to extract the Attr property value of the test label, build the string that contains the label yourself
<test attr= "DDD" >
<test attr/s*=/s*["¦ '" (. *?) [¦ '].*?>
10. Use the socket correlation function (non-C URL) to implement the following function: Construct a POST request to send to the specified request path (such as Http://www.example.com:8080/test) to the specified port on the specified HTTP server. The request contains the following variables:
User name (username): a gentle knife
Password (PWD):&123=321&321=123&
Personal Profile (Intro): Hello world!
And the HTTP server requires the following cookies for simple user action tracking:
Cur_query:you&me
LAST_TM: ... (Last requested Unix timestamp, 10 minutes before the current request time)
CUR_TM: ... (The current requested UNIX timestamp)
The setting timeout is 10 seconds, and the response content of the HTTP server is exported after the request is made. Copy Content to Clipboard
Code:Function encode ($data, $sep = ' & ') {
while (the list ($k, $v) = each ($data)) {
$encoded. = ($encoded? "$sep": "");
$encoded. = Rawurlencode ($k). = ". Rawurlencode ($v);
}
return $encoded;
}
Function Post ($url, $post, $cookie) {
$url = Parse_url ($url);
$post = Encode ($data, ' & ');
$cookie = Encode ($cookieArray, '; ');
$fp = Fsockopen ($url [' Host '], $url [' Port ']? $url [' Port ']: $errno, $ERRSTR, 10);
if (! $fp) return "Failed to the open socket to $url [host]";
Post ($url, $post, $cookie); 11. What methods do you use to check the efficiency of the PHP script (usually the script execution time) and the efficiency of the database SQL (usually the database query time), and locate and analyze the bottleneck of the script execution and database query.
1. Script execution time, enable Xdebug, use Wincachegrind analysis.
2. database query, MySQL use explain analysis query, enable slow query log slow queries.
PHP LAMP Engineer Test Paper Question 1
What does. echo Count ("123")?> print out?
A) 3
B) False
C) Null
D) 1
E) 0
Question 2
Which of the following snippets prints a representation of the with two decimal places?
A) printf ("%.2d/n", 42);
B) printf ("%1.2f/n", 42);
C) printf ("%1.2u/n", 42);
Question 3
Given
$text = ' content-type:text/xml ';
Which of the following prints ' Text/xml '?
A) Print substr ($text, STRCHR ($text, ': '));
B) Print substr ($text, STRCHR ($text, ': ') + 1);
C) Print substr ($text, Strpos ($text, ': ') + 1);
D) Print substr ($text, Strpos ($text, ': ') + 2);
E) Print substr ($text, 0, STRCHR ($text, ': ')
Question 4
What is the value of $a?
<?php
$a = In_array (' $ ', Array (' 1 ')) = = Var_dump (' 01 ' = 1);
?>
A) True
B) False
Question 5
What is the value of $result in the following PHP code?
<?php
function Timestwo ($int) {
$int = $int * 2;
}
$int = 2;
$result = Timestwo ($int);
?>;
Answer:null
Question 6
The code below ___________ because ____________.
<?php
Class Foo {
?>
<?php
function Bar () {
print "Bar";
}
}
?>
A) would work, class definitions can be split up into multiple PHP blocks.
B) would not work, class definitions must is in a single PHP block.
C) would not work, class definitions must is in a single file but can is in multiple PHP blocks.
D) would work, class definitions can be split up into multiple files and multiple PHP blocks.
Question 7
When turned on, ____________ 'll _________ your script with different variables from HTML forms and cookies.
A) Show_errors, enable
B) Show_errors, show
C) Register_globals, enhance
D) Register_globals, inject
Question 8
What would be the output of the following PHP code:
<?php
echo Count (strlen ("http://php.net"));
?>
Answer:1
Question 9
What is the best all-purpose way of comparing two strings?
A) Using the Strpos function
B) Using the = = operator
C) Using strcasecmp ()
D) Using strcmp ()
Question 10
What is the difference between "print ()" and "Echo ()"?
Answer:print is a function,echo is a language construct
Sina:1. Write a function, as efficiently as possible, to remove the file extension from a standard URL
For example: http://www.sina.com.cn/abc/de/fg.php?id=1 need to remove PHP or. php
2. In the HTML language, the META tag for the header of the page can be used to output the encoded format of the file, the following is a standard META statement
<meta http-equiv= ' content-type ' content= ' text/html; CHARSET=GBK ' >
Write a function using the PHP language to change the charset portion of a standard HTML page similar to a meta tag to Big5
Please note:
(1) need to process the full HTML page, that is, not only this meta statement
(2) Ignore case
(3) ' and ' is interchangeable in this place
(4) ' content-type ' Both sides of the quotation marks can be ignored, but ' text/html; CHARSET=GBK ' on either side of the
(5) Pay attention to handling extra space
3. Write a function to calculate the relative path of two files
If $a = '/a/b/c/d/e.php ';
$b = '/a/b/12/34/c.php ';
Calculate the relative path of the $b relative to the $a should be ... /.. /C/D () to add ()
4. Write a function that can traverse all files and subfolders under a folder.
5. Describe the implementation principle of infinite classification in the forum.
6. Design a Web page that opens a Full-screen window with a text box and a button. When the user enters the information in the text box and clicks the button, it closes the window and the information is displayed on the main page.
Yahoo:1. Which of the following won't add John to the users array? Copy Content to Clipboard
Code:1. $users [] = ' John ';
2. Array_add ($users, ' John ');
3. Array_push ($users, ' John ');
4. $users | | = ' John '; 2. What ' s The difference between sort (), Asort () and Ksort? Under what circumstances would you with each of these?
3. What would the following code print to the browser? Why? Copy Content to Clipboard
Code: $num = 10;
function Multiply () {
$num = $num * 10;
}
Multiply ();
Echo $num; 4. What is the difference between a reference and a regular variable? How does your pass by reference & why would your want to?
5. What functions can you add library code to the currently running script?
6. What is the difference between foo () & @foo ()?
7. How did you debug a PHP application?
8. What does = = do? What ' s a example of something that would give true for ' = = ', but not ' = = '?
9. How would your declare a class named "My Class" with no methods or properties?
How would are you to create an object, which be an instance of "MyClass"?
How did you access and set properties of a class from within the class?
What is the difference between include & Include_once? Include & require?
What function would you with the redirect the browser to a new page? Copy Content to Clipboard
Code:1. Redir ()
2. Header ()
3. Location ()
4. Redirect () 14. What function can you with to open a file for reading and writing? Copy Content to Clipboard
Code:1. Fget ();
2. File_open ();
3. fopen ();
4. Open_file (); What ' s The difference between mysql_fetch_row () and mysql_fetch_array ()?
What does the following code do? Explain what ' s going on there. Copy Content to Clipboard
Code:$date = ' 08/26/2003 ';
Print ereg_replace ([0-9]+)/([0-9]+)/([0-9]+), 2/1/3, $date); Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
What ' s The difference between the way PHP and Perl distinguish between arrays and hashes?
How can I/round the stateless nature of HTTP using PHP?
What does the GD library do?
Name a few ways to output (print) A blocks of HTML code in PHP?
is PHP better than Perl? –discuss.
Baidu:The first part:
1. Explain the meaning of the following statement: document.form["FormName"].SUBMIT;
2. There are the following statements:
<input id= "txt" type= "text" value= "Baidu"/>
Write code that automatically selects the contents of the text box when the mouse is over the text box.
3. Converts the character 09 to decimal digits.
4. Convert 1234567890 to 1,234,567,890 each 3-digit form separated by commas.
5. About HTML and CSS, forget it.
6. Enter a year in the text box to determine its zodiac and output it next to the text box.
Both HTML and Javaservlet are required to write.
7.Ajax fetch data from server {id:123, name: "Baidu", Username: "MM", checked:true};
The value corresponding to the analysis name ("Baidu"). (long title, not remember)
8. Talk about the customer experience issue.
Part II:
1.Ajax, database triggers, GUI, interrupt mechanism of the common idea. Talk about this kind of thought (mechanism).
2. The first letter of all words in an English document is capitalized and the document exists in Doc.txt. You can choose from a variety of programming languages (c/c++,java,php ...) Write out your ideas and optimize your programs as much as possible.
3. About the tree's data structure.
4. Database optimization:
There is a table PRODUCT (Id,name,price,count);
The speed is always slow when executing a query:
SELECT * from PRODUCT WHERE price=100;
Add a nonclustered index to the Price field, and the query speed is slow.
(1) Analyze the reason of slow query.
(2) How to optimize.
5.CREATE TABLE topid{
TopicID int NOT null primary key auto_increment,
Title text,
Author varchar (30),
Content blob,
isdeleted int
...//seems to have an index defined on the author.
}
CREATE TABLE reply{
TopicID int foreign Key,
Replyid int primary Key auto_increment,
Replyauthor varchar (30),
Replytime datetime,
Context blob
..//define an index and key
}
One for the topic table, one for the reply table.
1. Ask what is the problem with performance considerations.
2. The query reply time does not exceed a specific time period, the reply author name begins with the subject of Mike
The title to the following query:
SELECT * from topic where Replyid, select Replyid from reply where
Replyauthor like ' mike% ' and (CurrentTime ()-replytime<specialtime))
What is the disadvantage of considering the above query statement in terms of performance?
How to optimize.
Cool News:php&html Basic Operation Problem
There are three PHP files in the same directory, and the content is
a.php:-------
<?php function fa () {echo ' in function a/n ';}? >
b.php:-------
<?php include ' a.php ';?>
<?php function fb () {FA (); echo "in function b/n";}?>
c.php:-------
<?php include ' a.php ';?>
<?php include ' b.php ';?>
<?php FA (); FB ();?>
Use the browser to access c.php, please ask if there is a problem.
If there is a problem, please indicate the correction method and write the browser view effect
If there is no problem, please write the browser view effect
From the table login, select the SQL statement that contains all the information for the first 10 results of admin in the Name field
Accurately indicate the results of the following code
<table border=1 width=500 style= "Text-align:center;" >
<tr>
<TD rowspan=2 width=50% height=50>a</td>
<TD width=50% eight=25>d</td>
</tr>
<TR><TD width=50% height=25>b</td></tr>
<TR HEIGHT=25><TD colspan=2>c</td></tr>
</table>
Accurately indicate the results of the following code
<style>
. a {
position:relative;
height:200px;
width:500px;
Border:solid 1px #000;
Background: #FFF;
}
#b, #c {position:absolute; width:250px; height:90px;}
#b {top:30px;left:50px; background: #FF0000; z-index:1;}
#c {bottom:30px right:50px; background: #0000FF;}
</style>
<div class= "a" >
<div id= "B" ></div>
<div id= "C" ></div>
</div>
Please describe the meaning and role of DTDs in HTML documents
Determine if the following code is correct, and if it is wrong, indicate the error, and if correct, indicate the result of the operation
var arr = new Array (new Array (1,2,3,4),
New Array (' abc ', "Def", "XYZ"),
);
for (i = 0; i < arr.length; i++) {
document.write (arr [0])
}
How to use JavaScript to get the position of the upper-left corner of the current DOM element (obj) throughout the document
What methods can be used to make requests to the server using JavaScript and not to leave the current page, simply compare their characteristics (if present)
Please write a method to get the next self-growing ID value in PHP's MySQL connection and write multiple.
What is the difference between CGI and fastcgi, and under what circumstances will you choose
How to determine whether a string is a valid date pattern in PHP: 2007-03-13 13:13:13. Requires no more than 5 lines of code.
In PHP, how to get the key value of an array.
What's Zend Optimizer?
How to use the command to back up the data in MySQL
Linux Operations:
VI Editor, what are the commands for selecting, copying, pasting, and deleting
Get the number of rows in a file
Enter the last 5 lines of the file into another file
Find rows containing hello in a file
To find the commands for all subdirectories under the current directory named CVS
To delete all directories under the current directory named CVS
How to make a program run in the background and direct input to the specified file
How to add the contents of one file to the end of another file
How to display the output of a file in real time
What is the method for timing a program to execute?
VI Editor, how to replace the specified string
When the CVS Chinese pieces are in conflict when updated. How to tell what you're editing and what's being updated
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.