Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interview questions for PHP?

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the interview questions of PHP". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. What does _ _ FILE__ mean? (5 points)

The full path and file name of the file. If used in an include file, the include file name is returned. Since PHP4.0.2, _ _ FILE__ always contains an absolute path, while previous versions sometimes included a relative path.

2. How to obtain the IP address of the client? (5 points)

$_ SERVER ['REMOTE_ADDR']

3. Write a statement that uses the header function to jump to the page (5 points)

Header ('location:index.php')

4. $str is a piece of html text, using regular expressions to remove all js scripts (5 points)

$pattern='/\. + /'

Preg_replace ($pattern,'',$str)

5. Write a statement that removes null values from an array (5 points)

$arr=array (', 1, 1, 2, 2, 3, 3, 2, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 and 12, respectively.)

The first method:

$array1=array (', 1, 1, 2, 3)

Print_r (array_filter ($array1, "del"))

Functiondel ($var)

{

Return (trim ($var))

}

The second method:

$arr=array ("", 1pm 2pm 3, "")

$ptn= "/\ Shop I"

Print_r (preg_grep ($ptn,$arr))

6. Write the function to get the current timestamp and print the time of the previous day (format: year-month-day: minutes: seconds) (5 minutes)

Time ()

Date ("Y-m-dH:i:s", Strtotime ("- 1day"))

7. Write out the function of php for transcoding (5 points)

Iconv ('utf-8','gb2312',$str)

8, $str= "1 str= 3 # 5 # 7 7 # 9 10 # 20", what function can be used to convert the string str into an array containing individual numbers? (5 points)

Arr=explode (",", $str)

9. The function of serialize () / unserialize () function (5 points)

Serialize () and unserialize () are explained in the php manual as follows:

Serialize- produces a representation of a value that can be stored, and the return value is a string that contains a stream of bytes representing value, without losing its type and structure, and can be stored anywhere.

Unserialize- creates the value of PHP from the stored representation

Specific usage:

Arr=array ("Test 1", "Test 2", "Test 3"); / / array

$sarr=serialize ($arr); / / generate a storable value (for storage)

/ / use any method (for example, if you store $sarr in a text file, you can get it with file_get_contents) and save the stored value in $newarr.

$unsarr=unserialize ($newarr); / / create the value of PHP from the stored representation

10. Write a function with arguments of year and month, and output the number of days of the specified month (5 points)

Functionday_count ($year,$month) {

Echodate ("t", strtotime ($year. "-". $month. "- 1")

}

This is the end of the content of "what are the interview questions for PHP". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report