1. What is the difference between get and post submission methods in a form?
A: Get is a send request HTTP protocol to receive via URL parameter delivery, while post is entity data that can be submitted with a large amount of information through a form. What is the difference between a session and a cookie?
(1), the session is saved in the server, the client cannot obtain the information therein; The cookie is stored on the client and the server is able to obtain the information.
(2), session can not distinguish between the path, the same user during a visit to a website, all sessions can be accessed in any place. In the cookie, if the path parameter is set, the cookies under different paths in the same Web site are inaccessible to each other.
(3), the session requires the use of cookies to work properly. If the client completely disables the cookie and does not pass through the URL, the session will be invalidated.
(4), cookies are not very secure, others can analyze cookies stored locally and make cookie spoofing
Consider that security should use the session.
2. What are the transactions in the database?
A: a transaction (transaction) is an ordered set of database operations. If all operations in the group are successful, the transaction is considered successful and the transaction is unsuccessful even if only one operation fails. If all operations are completed, the transaction commits and its modifications are made to all other database processes. If an operation fails, the transaction is rolled back, and the effect of the firm's operations is canceled.
3. The time format for printing the previous day in PHP is 2006-5-10 22:21:21
Answer: Echo date (' y-m-d h:i:s ', Strtotime ('-1 day '));
4.echo (), print (), print_r () differences
Answer: ECHO is a PHP statement, print and Print_r are functions, the statement does not return a value, the function can have a return value (even if it is not used)
Print () prints only the values of a simple type variable (such as int,string)
Print_r () can print out values for complex type variables (such as arrays, objects)
echo outputs one or more strings
5. Templates that enable HTML and PHP to be separated from use
Answer: Smarty,dwoo,tinybutstrong,template lite,savant,phemplate,xtemplate
6. Which tools are used for version control?
Answer: CVS,SVN,VSS;
7. How do I implement string flipping?
Answer: Echo strrev ($a);
8. How to optimize MySQL database.
A: 1, select the most applicable field properties, to minimize the definition of field length, as far as possible to set the field not NULL, such as ' Province, gender ', preferably set to enum
2. Use connection (join) instead of subquery:
3. Use Union (Union) instead of manually created temporary table
4. Transaction processing:
5, lock the table, optimize transaction processing:
6, using foreign keys, optimize the locking table
7. Build the index:
8. Optimizing Query Statements
9.MYSQL the function that gets the current time is?, the function that formats the date is
Answer: Now (), date ()
10. The implementation of the text string interception without garbled method.
Mb_substr ()
function Gbsubstr ($string, $start, $length) {if (strlen ($string) > $length) {$str =null; $len = $start + $length; for ($i =$ Start, $i < $len, $i + +) {if (Ord (substr ($string, $i, 1)) >0xa0) {$str. =substr ($string, $i, 2); $i + +;} else{$str. =substr ($string, $i, 1);}} return $str. ' ... '; }else{return $string;}}
11. Have you ever used version control software? If you have the name of the version control software you are using?
TortoiseSVN;
12. What are the methods you use to solve traffic problems for large-volume websites?
A: Use the cache/image, verify that the server hardware is sufficient to support the current traffic, database read/write separation, optimize the data table, program function rules, prohibit external hotlinking, control the download of large files, use different host to divert the main traffic
13. How to modify the session lifetime
For:
Method 1: Set session.gc_maxlifetime in php.ini to 9999 restart Apache
Method 2:
$savePath = "./session_save_dir/";
$lifeTime = Hour * SECOND;
Session_save_path ($savePath);
Session_set_cookie_params ($lifeTime);
Session_Start ();
Method 3:
Setcookie () and Session_set_cookie_params ($lifeTime);
18, there is a web address, such as the PHP Development Resource Network homepage: http://www.scutephp.com/index.html, how to get its content?
Answer: Method 1 (for PHP5 and later versions):
$readcontents = fopen ("http://www.scutephp.com/index.html", "RB");
$contents = Stream_get_contents ($readcontents);
Fclose ($readcontents); Echo $contents;
Method 2:
Echo file_get_contents ("http://www.scutephp.com/index.html");
14, talk about the understanding of MVC
A: The application of the model, view, controller (controllers) completed by the model emitted to implement the function to the controller, the controller receives the organizational functions passed to the view;
16. Please indicate the difference between the value of the transfer and the reference in PHP. When is the value passed?
For:
Pass by value: Any changes to values within the function scope are ignored outside the function
Pass by reference: Any changes to values within a function can also reflect these changes outside of the function
Pros and Cons: When passing by value, PHP must copy the value. This can be a costly operation, especially for large strings and objects.
Passing by reference does not require copying values, which is good for performance gains.
17. What is the function of error_reporting in PHP?
Answer: Set error level and error message return
18. Please write a function to verify that the e-mail message is properly formatted
Answer: function Checkemail ($email) {$pregEmail = "/([A-z0-9]*[-_.]? [a-z0-9]+] *@ ([a-z0-9]*[-_]?[ a-z0-9]+) +[.] [A-z] {2,3} ([.] [A-z] {2})? /I "; Return Preg_match ($pregEmail, $email); }
19. Describe how to get the current execution script path, including the obtained parameters.
Answer: $script _name = basename (__file__); Print_r ($script _name);
21. JS Form Popup dialog function is? Get the input focus function?
Answer: Popup Dialog: Alert (), Prompt (), confirm () get input focus ()
22, JS's steering function is? How to introduce an external JS file?
Answer: Window.location.href,
23. What is the difference between foo () and @foo ()?
Answer: @foo () Ignore error output
24. How do I declare a class with no methods and properties named "MyClass"?
Answer: Class myclass{}
25. How to instantiate an object named "MyClass"?
Answer: New MyClass ()
26. How do you access and set the properties of a class?
Answer: $object = new MyClass (); $newstr = $object->test; $object->test = "info";
27. What is the difference between mysql_fetch_row () and mysql_fetch_array?
A: Mysql_fetch_row is a 1-row array taken from the result set, as an enumeration mysql_fetch_array a row of arrays from the result set as associative arrays, or arrays of numbers, both
28, what is the GD library for?
A: The GD library provides a series of APIs for working with images, using the GD library to process pictures, or to create images.
The GD library on the site is often used to generate thumbnails or to add watermarks to images or generate reports on site data.
36. Please write the meaning of the data type (int char varchar datetime text); What's the difference between varchar and char, please?
A: int is a numeric type, char fixed length string, varchar actual length string, DateTime date Time type, text text string char field fixed to create table set length, varchar is variable length character
39. Is there a function to detect whether a variable is set or not? is the function empty?
Answer: Isset ($str), Empty ($STR);
40. What is the function that gets the total number of query result sets?
Answer: mysql_num_rows ($result);
45. Please write PHP5 permission control modifier
Answer: Public, private (private), Protected (inherited)
46. Please write down the php5 constructor and destructor
Answer: __construct, __destruct
47. Create a table named message with the following fields
ID Article ID title article title content Article category_id article category ID hits click a: CREATE TABLE ' message ' (' id ' int ') not NULL Auto_increme NT, ' title ' varchar ($) default NULL, ' content ' text, ' category_id ' int (ten) not null, ' hits ' int (), PRIMARY KEY (' id '); ) Engine=innodb DEFAULT Charset=utf8;
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
Answer 1:end (Explode (', ', basename ($url)));
2. The execution of the program segment will output __0__.
The database connection string format in pear is ____.
$DSN = "Mysql://root:123@192.168.0.1/testdb";
6. Write a regular expression that js/vbs all the scripts on the Web page (that is, remove the scrīpt tag and its contents):
Preg_replace ("//si", "Newinfo", $script);
7. Install PHP in the Apache module, in the file http.conf the first to dynamically load the PHP module with the statement ____, and then use the statement ____ so that Apache will all files with the extension PHP as PHP script processing.
LoadModule php5_module "C:/php/php5apache2.dll",
AddType application/x-httpd-php. PHP,
3. What functions can I use to prevent SQL injection vulnerabilities?
Addslashes ()
Mysql_escape_string ()
4. Write code showing client IP and server IP in PHP
echo $_server[' REMOTE_ADDR '];
echo $_server[' server_addr '];
6. Write a function that can traverse all files and sub-files under a folder
{
$i = 1;
if ($handle = Opendir ($dir)) {
while (false!== ($file = Readdir ($handle))) {
if ($file! = "." && $file! = "...") {
if (Is_dir ($dir. " /". $file) = = True) {
$fullpath = $dir. " /". $file;
Dir_recurse ($fullpath);
echo "$fullpathn";
$i + +;
}else {
$fullpath = $dir. " /". $file;
echo "$fullpathn";
$i + +;
}
}
}
Closedir ($handle);
}
7, create the file Exer1, set the access rights to rw-r--r--, now to increase the execution rights of all users and the same group of users write permissions, write out the operation of the process command
Touch Exer1
chmod 644 Exer1
Increase permissions
chmod a+x Exer1
chmod g+w exer1 or chmod 775 exer1
8, the string "to upper case" respectively with the Php,shell, JS implementation of the characters in the string are all converted to uppercase and output.
PHP implementation: Echo Strtoupper (' to upper case ')
Shell implementation: echo "to upper case" | Tr ' A-Z ' A-Z
JS implementation:
9. Log in to MySQL database with root, if MyDB does not exist, create database mydb in MySQL, assign all permissions to root user to access Mysdb database from 192.168.1.1 IP. (The root user password is empty)
CREATE DATABASE IF not EXISTS mydb;
Grant all on mydb.* to root@ ' 192.168.1.1 ' identified by ';
11. In PHP, the name of the current script (not including the path and query string) is recorded in the predefined variable (1), while the URL linked to the current page is recorded in the predefined variable (2).
Answer: Echo $_server[' php_self ']; echo $_server["Http_referer"];
3. In HTTP 1.0, the meaning of status code 401 is (4); If you return a prompt for "file not found", the header function is available with the statement (5).
Answer: (4) Unauthorized (5) header ("http/1.0 404 Not Found");
4. The function of array function Arsort is (6); the function of statement error_reporting (2047) is (7).
A: (6) Reverse-order the array and keep the index relationship (7) all errors and warnings
7. Statements include and require can include another file in the current file, the difference is (12), in order to avoid multiple inclusion of the same file, you can use the statement (13) instead of them.
Answer: (12) When an exception occurs, the include generates a warning require a fatal error (require_once ()/include_once ()
8. 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).
Answer: Serialize ()/unserialize ()
9. The argument of a function cannot be a reference to a variable unless (15) is set to on in PHP.ini.
Answer: Allow_call_time_pass_reference
The meaning of the left join in 10.SQL is (16).
If Tbl_user records the student's name and school Number (ID),
Tbl_score recorded student (ID) and test scores (score) and test subjects (subject), which were expelled from the school after the exam,
To print out each student's name and the corresponding total, the SQL statement (17) can be used.
Answer: (16) Natural left outer connection
Select Name, count (score) as Sum_score from Tbl_user left join Tbl_score on Tbl_user.id=tbl_score.id GROUP by Tbl_us Er.id
11: In PHP, Heredoc is a special string, and its end flag must be (18).
A: The line where the end identifier is located cannot contain any other characters except ";"
14. How do I implement string flipping?
A: With Strrev function Bai, do not use PHP built-in on their own write:
Strrev ($STR)
{
$len =strlen ($STR);
$newstr = ";
for ($i = $len; $i >=0; $i--)
{
$newstr. = $str {$i};
}
return $newstr;
}
18. Get the extension of a file using more than five different ways
Requirements: dir/upload.image.jpg, find. jpg or JPG,
A: Use more than five ways to get the extension of a file
1)
Get_ext1 ($file _name)
{
Return STRRCHR ($file _name, '. ');
}
2)
GET_EXT2 ($file _name)
{
Return substr ($file _name, Strrpos ($file _name, '. '));
}
3)
GET_EXT3 ($file _name)
{
Return Array_pop (Explode ('. ', $file _name));
}
4)
GET_EXT4 ($file _name)
{
$p = PathInfo ($file _name);
return $p [' extension '];
}
5)
GET_EXT5 ($file _name)
{
Return Strrev (substr (Strrev ($file _name), 0, Strpos (strrev ($file _name), '. '));
}
30. Please give an example of how you can speed up the loading of pages in your development process.
A Generating static HTML
B Generate XML
C You can save variable parameters in text without using the database as far as possible without the database.
D Accelerate with Zend
21. How do I get the content of a Web page address using PHP's environment variables? How do I get an IP address?
Answer: $_servsr[' Request_uri ']
$_server[' REMOTE_ADDR ']
What is the difference between 25.mysql_fetch_row () and mysql_fetch_array ()?
Mysql_fetch_row () stores a column of the database in a zero-based array, the first column in the array index 0, the second column at index 1, and so on. MYSQL_FETCH_ASSOC () stores a column of the database in an associative array, the index of the array is the column name, for example, my database query back to "First_Name", "last_name", "e-mail" three fields, the index of the array is "first _name "," last_name "and" email ". Mysql_fetch_array () can send back the values of Mysql_fetch_row () and MYSQL_FETCH_ASSOC () at the same time.
29. Prevent SQL injection vulnerability generally with the __addslashes___ function.
What is the difference between a value in 30.PHP and a pass-through or address?
A: The value of the argument is the value assigned to the parameter to the row parameter, so the modification of the parameter does not affect the value of the argument.
An address is a special way of transmitting a value, except that he passes an address, not an ordinary one, such as an int. After the address, both the argument and the row parameter point to the same object
31. How to tell if a window has been blocked by JavaScript
A: Gets the return value of open (), or null if it is blocked
33. What are the ways you can solve traffic problems for large-volume websites?
A: 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, using traffic analysis statistics software