Write a function that is as efficient as possible to retrieve the file extension from a standard url such as: http://www.test.com.cn/abc/de/fg.php? Id = 1 need to retrieve php or. php
Write a function that is as efficient as possible to retrieve the file extension from a standard url such as: http://www.test.com.cn/abc/de/fg.php? Id = 1 need to retrieve php or. php
A: 1, $ a = "http://www.test.com.cn/abc/de/fg.php? Id = 1 ";
2. $ B = parse_url ($ );
3. Echosubstr ($ B ['path'], strpos ($ B ['path'], '.'); or:
4. Echoend (explode ('.', $ B ['path']); 2
Describe the solution for high-traffic and high-concurrency websites
Answer: 1. check whether the server hardware is sufficient to support the current traffic.
2. use the memcache cache technology to cache dynamic data into the memory. dynamic webpages directly call these files without having to access the database.
3. external leeching is prohibited.
4. image or file leeching on external websites often results in a lot of load pressure. Therefore, we should strictly limit external attempts to leeching on images or files. At present, we can simply use refer to control leeching, apache can disable leeching through configuration.
5. control the download of large files. Large file downloads consume a lot of traffic, which is consumed by non-SCSI hard disks, reducing the website response capability.
6. use different hosts to distribute major traffic
7. use traffic statistics software. Install a traffic statistics software on your website to instantly know where traffic is consumed and which pages need to be optimized.
8. Database/table sharding.
9. sphsf-full-text index engine.
How to design or configure Mysql for efficient use.
A:
1. in terms of database design, a database with a good design structure allows some data redundancy. Select the most suitable field attribute and set the field as NOTNULL as much as possible. in this way, when querying, the database does not need to compare NULL values.
2. in terms of system architecture design, the table is hashed, and massive data is hashed into several different tables. clusters, database queries, and writes are separated. Write efficient SQL statements to improve efficiency. Join is used to replace subqueries. union is used to replace the temporary tables created manually. only necessary data is obtained from the database. Different storage engines are required. for example, Innodb can reduce deadlocks and HEAP can increase the query speed by an order of magnitude.
Using foreign keys for transactions using indexes 24. how do I prevent SQL injection?
A:
1. filter out some common database operation keywords, such as select, insert, update, delete, and, or through the system function: addslashes (content to be filtered.
2. in the PHP configuration file, Register_globals = off. set it to disabled. // disable the registered global variable. For example, to receive the value of the POST form, use $ _ POST ['user']. if register_globals = on;, use $ user to directly receive the value of the form.
3. when writing SQL statements, try not to omit small quotation marks (the one above the tab key) and single quotation marks.
4. improve database naming skills. important fields are named based on program characteristics, which are hard to be guessed.
5. encapsulate common methods to avoid direct leakage of SQL statements
6. enable the PHP Security mode Safe_mode = on;
7. enable magic_quotes_gpc to prevent SQL injection Magic_quotes_gpc = off. by default, it is disabled. after it is enabled, it automatically converts the query of the SQL statement submitted by the user and converts '\', this plays a major role in preventing SQL injection. Enable magic_quotes_gpc = on;
8. disable the error message and write the error message to the system log.
9. use mysqli or pdo for preprocessing.
What should I pay attention to when writing a secure user login system using PHP.
A:
1. Use MD5 (password + string) for password encryption.
2. the name of the logon form should not be the same as that of the database field to avoid brute-force table fields.
3. it is difficult to guess the table name, field name, and password of a user table.
4. use the verification code to verify logon to prevent brute-force cracking.
5. verify that the submitted data is from this website.
6. log on to the background to process the code. use preprocessing to filter and prevent SQL injection.
Which PHP frameworks have been used. Describe the advantages and disadvantages.
A:
1. BroPHP framework: Advantages: lightweight learning framework, simple configuration, simple operation, easy to use, and comprehensive documentation. Disadvantages:
2. ThinkPHP frame: Advantages: comprehensive functions, relatively simple configuration, relatively simple operations, and many sample programs. Disadvantages: there are too many operation methods available for beginners, and the document is not comprehensive enough.
Which version control tools have you used?
A: I have used the SVN version controller.
When the output is Mozilla/4.0 (compatible; MSIE5.01; Window NT 5.0), the possible output statement is: B
A. $ _ SERVER ['http _ USER_AGENT_TYPE '];
B. $ _ SERVER ['http _ USER_AGENT '];
C. $ _ SERVER ['User _ agent'];
D. $ _ SERVER ['agent'];
Which of the following functions cannot be implemented by PHP? D
A. run the server script
B. run the command line script
C. client GUI program
D. perform DOM operations on the browser.
Which of the following statements is false? C
A. PHP has four scalar types: boolean, integer, float, and string)
B. float and double are of the same type.
C. conformity types include: array, object, and resource)
D. pseudo type: mixed type (mixed), number type (number), callback (callback)
The following functions are not part of PHP syntax: AD
A. array B. eval C. each D. list
What is the result of executing the following code? A
A. boolean
B. boolean0
C. booleanFALSE
D. booleanfalse
What is the difference between a SESSION and a COOKIE? please refer to the protocol, the reasons for its occurrence and the description of its role?
A:
1. the http stateless protocol does not distinguish whether a user is from the same website. different pages requested by the same user cannot be regarded as the same user.
2. the SESSION is stored on the server, and the COOKIE is stored on the client. the SESSION depends on the COOKIE for transmission. if the COOKIE is disabled, the SESSION cannot be used any more.
What are the meanings of codes 302, 403, and 500 in HTTP status?
A:
300 redirection, 403 server access denied, and 500 server internal error.
Create a compressed package in Linux and decompress the package command.
A:
1. compression: gzip, tar cvfz, zip, bzip22, decompress: gunzip, tar zxvf, unzip, bunzip2
$ A = 3; $ B = 4; if ($ a | $ B = 5) {||or | difference echo 'Todo ';} the value of $ B is ():
A a. 4; B. 5; c. 3; d. false
What is object-oriented? What are the main features?
A:
1. object-oriented is a design method of a program. it helps improve the reusability of the program and makes the program structure clearer.
2. main features: encapsulation, inheritance, and polymorphism.