PHP interview questions and answers
2. echo(), The difference between print() and print_r() (3 points)
3. A template that can be used separately from html and php (1 point) smarty,phplib 4. What tools are used for version control? (1 point) svn,git,cvs 5. How to implement string flipping? (3 points) English: strrev($a) Chinese or other text: Chinese: gb2312, the code is encoded using gb2312
6. Methods to optimize mysql database. (4 points, write more and get more) In terms of sentences: 1 Use indexes to increase query efficiency 2 Optimize query statements and improve index hit rate Database aspects involved: 1 Construct sub-databases and tables to improve the storage and expansion capabilities of the database 2 Use different storage engines as needed 7. The meaning of php (send 1 point) hypertext preprocessing language hypertext preprocessor 8. What is the function of MySQL to obtain the current time?, and the function of formatting the date is (2 points)
9. A method to intercept Chinese strings without garbled characters. (3 points)
mb_substr($str, 1, 1, "gb2312");
10. Have you ever used version control software? If so, what is the name of the version control software you used? (1 point)
svn
git
11. Have you ever used a template engine? If so, what is the name of the template engine you used? (1 point)
smarty
12. Please briefly describe your most proud development work (4 points)
xxx
13. For websites with large traffic, what methods do you use to solve the traffic problem? (4 points)
1 Effectively use cache to increase cache hit rate
2 Use load balancing
3 Use CDN to store and accelerate static files
4 ideas to reduce database usage
5 Check where the statistical bottlenecks are
14. Use PHP to write the code that displays the client IP and server IP (1 point)
$_server["remote_addr"]
$_server["server_addr"]
15. What is the difference between the include and require statements? To avoid including the same file multiple times, they can be replaced by (?) statements? (2 points)
On failure:
include generates a warning, while require generates an error interrupt directly.
require is loaded before running
include is loaded at runtime
require_once
include_once
16. How to modify the session survival time (1 point).
session_set_cookie_params
17. There is a web page address, such as the Scripting School homepage: http://bbs.it-home.org/index.html, how to get its content? ($1 point)
file_get_contents
curl
18. In http 1.0, the meaning of status code 401 is (?); if the prompt "File not found" is returned, the header function can be used, and its statement is (?); (2 points)
unauthorized
header("http/1.0 404 not found");
In fast cgi:
header("status: 404 not found");
19. In PHP, heredoc is a special string, and its end mark must be? (1 point)
appear in pairs
$a = < 26. Briefly describe how to get the current execution script path, including the obtained parameters. (2 minutes)
$argc -- Get the number of parameters
$argv -- Get the parameter list
27.How to modify the session survival time. (1 point)
session_set_cookie_params
28. What is the function for popping up a dialog box in a js form? What is the function for obtaining input focus? (2 points)
alert()
confirm()
prompt()
focus()
29. What is the redirection function of js? How to introduce an external js file? (2 points)
window.location.href="#"
30. What is the difference between foo() and @foo()? (1 point)
@ represents all warnings to be ignored
31. How to declare a class named "myclass" without methods and attributes? (1 point)
class myclass
{
}
32. How to instantiate an object named "myclass"? (1 point)
$myclass = new myclass();
33. How do you access and set the attributes of a class? (2 points)
34. What is the difference between mysql_fetch_row() and mysql_fetch_array? (1 point)
mysql_fetch_array() is an extended version of mysql_fetch_row(). In addition to storing data in an array as a numerical index, you can also store data as an associative index, using the field name as the key.
35. What is the gd library used for? (1 point)
Dynamic and open image processing library
36. Point out some ways to enter a piece of html code in php. (1 point)
37. Which of the following functions can open a file to read and read the file? Write operation? (1 point) c
(a) fget() (b) file_open() (c) fopen() (d) open_file()
38. Which of the following options does not add john to the users array? (1 point) b
39. Will the following program be entered? (1 point) 10
40. Use PHP to write a simple query to find all the content named "Zhang San" and print it out (2 points)
Table name username tel content date
Zhang San 13333663366 Graduated from college 2006-10-11
Zhang San 13612312331 Undergraduate degree 2006-10-15
Zhang Si 021-55665566 Graduated from technical secondary school 2006-10-15
Please complete the code according to the above question:
41. How to use the following classes and explain what they mean? (3)
Connect the 32-bit string a1 generated after md5 encoding of num with "en" and then perform md5 encoding again
42. Write the format of sql statement: insert, update, delete (4 points)
Table name username tel content date
Zhang San 13333663366 Graduated from college 2006-10-11
Zhang San 13612312331 Undergraduate 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 graduated from high school 2007-05-06). Please use sql statement to add it to the table
insert into table name values('Xiao Wang', '13254748547', 'High School Graduation', '2007-05-06')
(b) Please use sql statement to update Zhang San’s time to the current system time
update table name set date = getdate() where username = "Zhang San"
(c) Please write to delete all records named Zhang Si
delete from indicates where username = "Zhang Si"
43. Please write down the meaning of data type (int char varchar datetime text); what is the difference between varchar and char (2 points)
int integer type
char storage fixed length
varchar storage variable length
datetime time
text stores variable length
varchar is variable length
char(20) fixed length
44. The mysq auto-increment type (usually the table id field) must be set to a (?) field (1 point)
auto_increment
45. Write the output of the following program (1 point)
$b=201;
$c=40;
a=b>$c?4:5;
echo $a;
?>
4 46. Is there a function to detect whether a variable is set? What is the function to detect whether it is empty? (2 points)
isset()
empty()
47. What is the function to obtain the total number of query result sets? (1 point)
mysql_num_rows()
48.
49. Please Separate the values of the array in question 41 with ',' signs and merge them into string output (1 point)
implode
50. a=′abcdef′; Please take out the value of a and print out the first letter (1 point)
$a[0];
substr($a, 0, 1);
51. Can php be connected to databases such as sql server/oracle? (1 point)
Can
There are ready-made libraries
52. Please write the php5 permission control modifier (3 points)
public
private
protected
53. Please write down the constructor and destructor of php5 (2 points)
public function __construct()
{
}
public function __destruct()
{
}
Programming questions
1. Write a function to retrieve the file extension from a standard URL as efficiently as possible
For example: http://www.sina.com.cn/abc/de/fg.php?id=1 You need to remove php or .php
3. Write a function to calculate the relative paths of two files
Such as $a = '/a/b/c/d/e.php';
$b = '/a/b/12/34/c.php';
Calculate the relative path of b relative to a should be http://www.cnblogs.com/12/34/c.php will be added
3. Write a function that can traverse all files and subfolders in a folder.
|

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
