Table of Contents
 很多处理都是这些思路,如何判断汉字边界的问题,防止出现汉字截断。" >         很多处理都是这些思路,如何判断汉字边界的问题,防止出现汉字截断。
Home Backend Development PHP Tutorial Analysis of several interview questions about PHP

Analysis of several interview questions about PHP

Aug 09, 2017 pm 02:24 PM
php

1. Use PHP to print out the time of the previous day in the format of 2006-5-10 22:21:21

## $yesterday = mktime(0, 0 , 0, date("m") , date("d")-1 , date("Y"));

echo date("Y-M-d h:i:s" , $yesterday);

Note: mktime returns unix timestamp.

int mktime ([ int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst ]]]]]]]

 2. The difference between echo(), print(), print_r()

You can understand it by looking at the function definition on php.net:

#printOutput a string

##              

echoOutput one or more strings
#          

var_dump

Dumps information about a variable##            

print_r Prints human-readable information about a variable In addition:

                                                                              printf

—  

Output a formatted string                                                                          

sprintf

—   Return a formatted string

           

flush —   Flush the output buffer 3, the template that can separate HTML and PHP

# ste MARTY (very good template engine), PHPLIB , Fasttemplete,

php4 comes with (IntegratedTemplate, IntegratedTemplateExtension)

Another:

# 1. You can implement one yourself. Commonly used HTML tags such as select, input, etc. are convenient for program and database processing. Then use the program to call the static page containing the template tag. However, smarty is based on the caching mechanism. There is a templates_c directory to generate temporary files for storage. This aspect is relatively advanced. If you write it yourself, it will be more complicated.

2.Separating logic and performance is the right way, rather than simply separating HTML and PHP

3. Pay attention to the difference between template engines and frameworks, and consider it from the perspective of MVC.

## 4. What tools are used for version control?

# #      

svn,cvs, VSS(ms)## 5. How to achieve string flipping?

Strrev ()

## This If you consider sufficient (Chinese character problem), I find the following code:

#

1.function reverse($str)
{
     $len=strlen($str);
     $newstr = '';
     for($i=$len;$i>=0;$i--)
     {
         $newstr .= $str{$i};
     }
     return $newstr;
}

    2. join("",array_reverse(str_split($str,1))),str_split($str,1)函数按长度分割字符串。explode()按分割符分割字符串.

    3.function rev_str($str)
   {
    $len = strlen($str);
    for($i=0;$i<$len;$i++)
    {
      $temp_str=substr($str,0,1);
      if(ord($temp_str) > 127)
      {
         $i++;
         if($i<$len)
         {
           $new_str[]=substr($str,0,3);
           $str=substr($str,3);
          }
       }
   else
      {
        $new_str[]=substr($str,0,1);
        $str=substr($str,1);
      }
    }
    return join(array_reverse($new_str));
}
Copy after login

6. Methods to optimize MYSQL database.

Mainly from several perspectives: Optimizing hardware, optimizing disk, optimizing operating system, selecting application programming interface, etc.

                                                                                                                                                                                                         Reference: http://www.phpdo.net/index.php/optimization-mysql.html

Use index etc.  

7. What does PHP mean?


#  8、MYSQL取得当前时间的函数是?格式化日期的函数是

mysql: now() ; date_format();

              php:      time();   date();
Copy after login

  9、实现中文字串截取无乱码的方法。

其核心是处理中文问题,见blog:http://www.cnblogs.com/nbkhic/archive/2011/07/16/2108335.html

很多处理都是这些思路,如何判断汉字边界的问题,防止出现汉字截断。


  10、用PHP写出显示客户端IP与服务器IP的代码
              $_SERVER["SERVER_ADDR"]         这个是服务器ip
              $_SERVER["REMOTE_ADDR"]        这个是客户端ip
Copy after login
              _SERVER显示服务器和执行环境信息。http://php.net/manual/en/reserved.variables.server.php
Copy after login
  11、语句include和require的区别是什么?为避免多次包含同一文件,可用(?)语句代替它们?

include如果包含出错,报错继续执行。

requre如果出错,终止执行脚本。

requre_once() ; 包含一次

更深入一步理解:http://blog.csdn.net/followingturing/article/details/8102789

  12、如何修改SESSION的生存时间

通常是修改php.ini中某个配置项值,可google之。

  13、有一个网页地址, 比如PHP研究室主页: http://www.phpv.net/index.html,如何得到它的内容?

file_get_contents();

fopen()都可以。

复杂的话,用curl。

  14、在HTTP 1.0中,状态码401的含义是?; 如果返回“找不到文件”的提示,则可用 header 函数,其语句为?;

401:需要用户验证。 get_headers();

其它常用:200,301,302,404等等。 详见:http://baike.baidu.com/view/1790469.htm

  15、在PHP中,heredoc是一种特殊的字符串,它的结束标志必须?

非常好的一项技术,用好了很方便,本质一句话:字符串输出技术

http://blog.csdn.net/followingturing/article/details/8102862

#16. Talk about the advantages and disadvantages of ASP, PHP, JSP                                                                                          Me you in illiteracy and ignore it.

17. Talk about the understanding of the MVC ## Series, ignore it.

18. Write the SQL of the names of the ten people with the most posts, using the following table: members(id,username,posts,pass,email)

                           

select top 10 username from members order by posts desc.



 19. Please explain the difference between passing by value and passing by reference in PHP. When to pass value and when to pass reference? past. This If you want to change the variable value, you can pass the address to see the needs.

 20. What is the function of error_reporting in PHP?

            php.net says: “Sets which PHP errors are reported

”              25. Please write a function to verify whether the format of the email is correct (2 points)

 26. Briefly describe how to get the current execution script path, including the obtained parameters. (2 points)

27. How to modify the survival time of SESSION. (1 point)

28. The JS form pop-up dialog box function is ?What is the function to obtain input focus? (2 points)

29. What is the redirection function of JS? How to introduce an external JS file? (2 points)

30. What is the difference between foo() and @foo()? (1 point)

31. How to declare a class named "myclass" without methods and The class of the attribute? (1 point)

32. How to instantiate an object named "myclass"? (1 point)

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)

35. What is the GD library used for? (1 point)

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 write the file? (1 point)
 (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 Points)
 (a) $users[] = 'john';
 (b) array_add($users,'john');
 (c) array_push($users,'john');
 (d) $users ||= 'john';

39. Will the following program be input? (1 point)
 $num = 10;
 function multiply(){
$num = $num * 10;
 }
 multiply();
 echo $num;
 ?>

## 40. Use PHP to write a simple query to find out all the content named "Zhang San" and print it out (2 points)
Table Name UserName Tel Content Date
Zhang San13333663366 College graduate 2006-10-11 Code:
 $mysql_db=mysql_connect("local","root","pass");
 @mysql_select_db("DB",$mysql_db);
 41. How to use the following classes and explain what they mean? (3)
 class test{

 function Get_test($num){
 $num=md5(md5($num)."En");
 return $num;
 }
 }
42. Write the format of the SQL statement: insert, update, delete (4 points)
Table name UserName Tel Content Date

in the table (b) Please use sql statement to update Zhang San’s time to the current system time
(c) Please write to delete all the names named Zhang Si Record

43. Please write the meaning of data type (int char varchar datetime text); What is the difference between varchar and char (2 points)
44. MySQ auto-increment type (usually table ID field) must be set to (?) field (1 point)
45. Write the output results of the following program (1 point)
 $b=201;

 $c=40;

 $a=$b>$c? 4:5;
echo $a;
 ?>

 46. Check whether a variable is set Is the function? The function that is empty? (2 points)
47. What is the function that obtains the total number of query result sets? (1 point)
48. $arr = array('james', 'tom', 'symfony'); Please print out the value of the first element (1 point)

49. Please separate the values ​​of the array in question 41 with ',' and merge them into string output (1 point)

50. $a = 'abcdef'; Please take out the value of $a value and print out the first letter (1 point)

51. Can PHP be connected to databases such as sql server/oracle? (1 point)

52. Please write the PHP5 permission control modifier (3 points)

53. Please write the constructor and destructor of php5 (2 points)

54. Please use PHPMYADMIN to complete the following

(1) Create a news release system. The table name is message and has the following fields (3 points)
 id article id
 title article title
 content article content
 category_id article category id
Hits Number of clicks

(2) The same news release system as above: The comment table records the content of user replies, and the fields are as follows (4 points)
Comment_id reply id
id article id, associated with the id in the message table
comment_content reply content
Now need to be obtained by querying the database A list of article titles in the following format, sorted by the number of replies, with the highest reply at the top
Article id Number of clicks on the article title Number of replies
Use a SQL statement Complete the above query. If there is no reply to the article, the number of replies will be displayed as 0

(3) In the above content management system, the table category saves classification information, and the fields are as follows (3 points)
Category_id int(4) not null auto_increment;
category_name varchar(40) not null;
When the user enters an article, select it from the drop-down menu Define the article category
Write how to implement this drop-down menu

55. In PHP, the name of the current script (excluding path and query string) Recorded in the predefined variable ____; and the URL linking to the current page is recorded in the predefined variable ____.

 56. In HTTP 1.0, the meaning of status code 401 is ____; if a "File not found" prompt is returned, the header function can be used, and its statement is ____.

 57. The function of array function arsort is ____; the function of statement error_reporting(2047) is ____.

58.The database connection string format in PEAR is ____.

59. Write a regular expression to filter all JS/VBS scripts on the web page (that is, remove the scrīpt tag and its content): ____.

60. To install PHP as an Apache module, in the file http.conf, first use the statement ____ to dynamically load the PHP module, and then use the statement ____ to make Apache All files with the php extension are processed as PHP scripts.

61. Both the include and require statements can include another file into the current file. The difference between them is ____; in order to avoid including the same file multiple times, you can use the statement ___ _to replace them.

62. The attributes of a class can be serialized and saved to the session, so that the entire class can be restored later. The function used for this is ____.

63. The parameter of a function cannot be a reference to a variable, unless ____ is set to on in php.ini.

 64.The meaning of LEFT JOIN in SQL is____. If tbl_user records the student's name (name) and student number (ID), tbl_score records the student's (some students were expelled after the exam and there is no record of them) student number (ID) and test scores (score) as well as test subjects (subject), if you want to print out the name of each student and the corresponding total score of each subject, you can use the SQL statement____.

65. In PHP, heredoc is a special string, and its end mark must be ____.
 
 66. 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 Need to remove php or .php

 67. In HTML language, the page header The internal meta tag can be used to output the encoding format of the file. The following is a standard meta statement
Please use PHP language to write a function to convert the charset in a similar meta tag in a standard HTML page Part of the value is changed to big5
Please note:
1. The complete html page needs to be processed, that is, not just this meta statement
2 . Ignore case
 3. ' and " are interchangeable here
 4. The quotation marks on both sides of 'Content-Type' can be ignored , but 'text/html; charset=gbk' does not work on both sides
 5. Pay attention to handling extra spaces

 68. Write a function to calculate two The relative path of a file
For example $a = '/a/b/c/d/e.php';
$b = '/a/b /12/34/c.php';
Calculate that the relative path of $b relative to $a should be ../../c/d and add () to

69. Write a function that can traverse a All files and subfolders under the folder.

70. Briefly describe the implementation principle of infinite classification in the forum.

71. Use PHP to describe bubble sorting and quick sorting algorithms. The object can be an array

​ ​​

72. Use PHP to describe sequential search and binary search (also called half search) algorithms. Sequential search must consider efficiency, and the object can be an ordered array

73. Write a two-dimensional array sorting algorithm function that can be universal and can call the PHP built-in function










The above is the detailed content of Analysis of several interview questions about PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles