Home  >  Article  >  Backend Development  >  PHP written test questions and interview questions, PHP test questions and interviews_PHP tutorial

PHP written test questions and interview questions, PHP test questions and interviews_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:44:302008browse

PHP written test questions and interview questions, PHP test questions and interviews

1. Directly exchange the values ​​of the two existing variables without new variables

<span>(1)list($a,$b)=array($b,$a);
(2)a=a+b,b=a-b,a=a-b</span>
2. Convert digital amounts to large and small formats in PHP and explain the idea at the same time
<span>function daxie($num){
      $da_num = array('零','一','二','三','四','五','六','七','八','九');
      $return = '';
      $len_num = strlen($num);
      if(!is_numeric($num) || $len_num < 0){
          return '';
      }
      for($i=0;$i<$len_num;$i++){
          $return .= $da_num[ substr($num,$i,1)];
      }
      return$return;
  }</span>
3. The SQL query statement is as follows:
select * from table where (ID = 10) or (ID = 32) or (ID = 22) or (ID = 76) or (ID = 13) or (ID = 44) Let the results be retrieved in the order of 10, 32, 22, 76, 13, 44. How to write it?
<span>select * from table
where id in (10,32,22,76,13,44)          
order by charindex(id,'10,32,22,76,13,44') desc</span>

4. Use PHP to print out the time of the previous day, the format is 2006-5-10 22:21:21

(1)echo date('Y-m-d H:i:s',time()-60*60*24); (2)echo date('Y-m-d H:i:s',strtotime('-1 day'))
(1)echo date('Y-m-d H:i:s' code><code>,time()-60*60*24);

(2)echo date('Y-m-d H:i:s' code><code>,strtotime('-1 day'))

echo是语言结构,无返回值;print功能和echo基本相同,不同的是print是函数,有返回值;print_r是递归打印,用于输出数组或对象
5. The difference between echo(), print(), print_r()

echo is a language structure with no return value; print function and echoBasically the same, the difference is thatprint is a function with a return value; print_r is recursive printing, used to output arrays or objects
<span>PHP本身是一种模版引擎,我用过的是smarty,常见的还有PHPLib,FastTemplate,Savant</span>

6. Templates that can separate HTML and PHP

PHP itself is a template engine. I have used smarty. Common ones include PHPLib, FastTemplate, and Savant<table border="1" cellspacing="0" cellpadding="2"> <tbody> <tr> <td> <code><span>CVS和SVN,SVN号称下一代CVS,功能强大,不过CVS是老牌,市占率很高.CVS Server on Apache作服务端,WinCVS作客户端;0c6dc11e160d3b678d68754cc175188aSubversion on Apache/DAV 做服务端,TortoiseSVN做客户端,或者Subclipse做客户端</span>

7. What tools are used for version control?

<table border="1" cellspacing="0" cellpadding="2"> <tbody> <tr> <td> <span><code>其实PHP本身就有字符串翻转的函数:strrev(),不过这种方法都不能解决中文字符串翻转的问题,会出错的。 <span>a1d11877e1e8225b669b936fdf57647f</span>
CVS and SVN, SVN is known as the next generation of CVS and has powerful functions, but CVS is an old brand with a high market share. CVS Server on Apache is used as the server, and WinCVS is used as the client;0c6dc11e160d3b678d68754cc175188aSubversion on Apache /DAV is used as the server, TortoiseSVN is used as the client, or Subclipse is used as the client 8. How to implement string flipping?
In fact, PHP itself has a function for flipping strings:strrev(), but this method cannot solve the problem of Chinese string flipping. Something went wrong. cd1107d947da78d30b84f947cd9f9811
9. Methods to optimize MYSQL database
<table border="1" cellspacing="0" cellpadding="2"> <tbody> <tr> <td> <code><span>(1).数据库设计方面,这是DBA和Architect的责任,设计结构良好的数据库,必要的时候,去正规化(英文是这个:denormalize),0c6dc11e160d3b678d68754cc175188a    允许部分数据冗余,避免JOIN操作,以提高查询效率</span> <span>(2).系统架构设计方面,表散列,把海量数据散列到几个不同的表里面.快慢表,快表只留最新数据,慢表是历史存档.集群,主服务器Read & write,0c6dc11e160d3b678d68754cc175188a    从服务器read only,或者N台服务器,各机器互为Master</span> <span>(3).(1)和(2)超越PHP Programmer的要求了,会更好,不会没关系.检查有没有少加索引</span> <span>(4).写高效的SQL语句,看看有没有写低效的SQL语句,比如生成笛卡尔积的全连接啊,大量的Group By和order by,没有limit等等.0c6dc11e160d3b678d68754cc175188a    必要的时候,把数据库逻辑封装到DBMS端的存储过程里面.缓存查询结果,explain每一个sql语句</span> (5).所得皆必须,只从数据库取必需的数据,比如查询某篇文章的评论数,select count(*) … where article_id = ? 0c6dc11e160d3b678d68754cc175188a    就可以了,不要先select * … where article_id = ?然后msql_num_rows.     只传送必须的SQL语句,比如修改文章的时候,如果用户只修改了标题,那就update … set title = ? where article_id = ?0c6dc11e160d3b678d68754cc175188a    不要set content = ?(大文本) <span>(6).必要的时候用不同的存储引擎.比如InnoDB可以减少死锁.HEAP可以提高一个数量级的查询速度</span>
(1). In terms of database design, this is the responsibility of the DBA and Architect. Design a well-structured database. When necessary, denormalize (English is this: denormalize), 0c6dc11e160d3b678d68754cc175188a Allow some data Redundant, avoid JOIN operations to improve query efficiency

<span>(2). In terms of system architecture design, table hashing is used to hash massive data into several different tables. Fast and slow tables, the fast table only retains the latest data, and the slow table is a historical archive. Cluster, Master server Read & write,0c6dc11e160d3b678d68754cc175188a Slave server read only, or N servers, each machine is the Master of each other</span> (3). (1) and (2) exceed the requirements of PHP Programmer, it will be better, it doesn’t matter. Check whether there are less indexes <table border="1" cellspacing="0" cellpadding="2"> <tbody> <tr> <td> <span><code>echo '客户端IP:'.$_SERVER['REMOTE_ADDR'].'df250b2156c434f3390392d09b1c9563'; echo '服务器端IP:'.gethostbyname($_SERVER['SERVER_NAME']); <p>(4). Write efficient SQL statements and see if there are any inefficient SQL statements, such as full joins that generate Cartesian products, a large number of Group By and order by, no limit, etc. 0c6dc11e160d3b678d68754cc175188a When necessary, encapsulate the database logic into the stored procedure on the DBMS side. Cache the query results and explain each SQL statement <span></span></p> (5). All results are required. Only obtain necessary data from the database, such as querying the number of comments on an article, select count(*) … where article_id = ? 0c6dc11e160d3b678d68754cc175188a That’s it, don’t select * first … where article_id = ? Then msql_num_rows.
(1)$_SERVER['SCRIPT_FILENAME'];或者$_SERVER['PHP_SELF']0c6dc11e160d3b678d68754cc175188a(2)$_SERVER['HTTP_REFERER'] (3)$_SERVER['SCRIPT_FILENAME'];0c6dc11e160d3b678d68754cc175188a(4)$_SERVER['REMOTE_ADDR'];0c6dc11e160d3b678d68754cc175188a(5)$_SERVER['QUERY_STRING'];0c6dc11e160d3b678d68754cc175188a(6)$_server['DOCUMENT_ROOT'];
Only transmit necessary SQL statements. For example, when modifying an article, if the user only modifies the title, then update... set title = ? where article_id = ?0c6dc11e160d3b678d68754cc175188a Don’t set content = ?(large text)

<span>(6). Use different storage engines when necessary. For example, InnoDB can reduce deadlocks. HEAP can increase query speed by an order of magnitude</span>

(1)echo 8%(-2)。输出:0 (2)echo (-8)%3 .输出:-2 (3)echo 8%(-3).输出:2
10. Use PHP to write the code to display the client IP and server IP:

echo 'Client IP:'.$_SERVER['REMOTE_ADDR'].'df250b2156c434f3390392d09b1c9563';
<span>arsort:对数组进行逆向排序并保持索引关系</span> error_reporting(2047)的作用是:report All errors and warnings
echo 'Server IP:'.gethostbyname($_SERVER['SERVER_NAME']);
11. In PHP, the name of the current script (excluding path and query string) is recorded in the predefined variable (1); and the URL linking to the current page is recorded in the predefined variable (2) middle. The absolute path name of the previously executed script (3), the IP address of the user browsing the current page (4), the query string (the content after the first question mark? in the URL): id=1&bi=2(5 ), the document root directory where the currently running script is located (6).
(1)$_SERVER['SCRIPT_FILENAME']; or $_SERVER['PHP_SELF']0c6dc11e160d3b678d68754cc175188a(2)$_SERVER['HTTP_REFERER'] (3)$_SERVER['SCRIPT_FILENAME'];0c6dc11e160d3b678d68754cc175188a( 4)$_SERVER['REMOTE_ADDR'];0c6dc11e160d3b678d68754cc175188a(5)$_SERVER['QUERY_STRING'];0c6dc11e160d3b678d68754cc175188a(6)$_server['DOCUMENT_ROOT'];
12. Executing the program segment will output __.
(1)echo 8%(-2). Output: 0 (2)echo (-8)%3. Output: -2 (3)echo 8%(-3).Output: 2
13. The function of array function arsort is ____; the function of statement error_reporting(2047) is ____.
arsort: Sort the array in reverse and maintain the index relationship The function of error_reporting(2047) is: report All errors and warnings
14. Write a regular expression to filter all JS/VBS scripts on the web page (that is, remove the script tag and its content):
$a="7c6ecc2a75ade4ffa1f50134f6be3b0eXXXXXXXXXXXXXXX2cacc6d41bbb37262a98f745aa00fbf0";0c6dc11e160d3b678d68754cc175188aecho preg_replace('/4bb16145477c7c68e128600db2a4279d]*?>.*2cacc6d41bbb37262a98f745aa00fbf0/is','',$a);
$a="7c6ecc2a75ade4ffa1f50134f6be3b0eXXXXXXXXXXXXXXXX2cacc6d41bbb37262a98f745aa00fbf0"; 0c6dc11e160d3b678d68754cc175188aecho preg_replace('/4bb16145477c7c68e128600db2a4279d]*?>.*2cacc6d41bbb37262a98f745aa00fbf0/ is','',$a);
15. Install PHP as an Apache module. In the file http.conf, first use the statement ____ to dynamically load the PHP module,

Then use the statement ____ to cause Apache to process all files with the extension php as PHP scripts.

LoadModule php5_module "c:/php/php5apache2.dll"; <span>AddType application/x-httpd-php .php</span>
LoadModule php5_module "c:/php/php5apache2.dll"; <table border="1" cellspacing="0" cellpadding="2"> <tbody> <tr> <td> <code><span>serialize() /unserialize()</span>
AddType application/x-httpd-php .php 16. The attributes of the class can be serialized and saved to the session, so that the entire class can be restored later. The function used is
serialize() /unserialize()
17.MySQL database, how to optimize it?

(1) Configuration optimization (server configuration) (2) Table creation optimization (table, field settings) (3) Query optimization (sql statement) Answer: 1. Select the most applicable field attributes and minimize them Define the field length, try to set the field to NOT NULL, such as 'province, gender', it is best to set it to ENUM 2. Use joins (JOIN) instead of subqueries: 3. Use unions (UNION) instead of manually created temporary tables 4 , Transaction processing: 5. Lock table, optimize transaction processing: 6. Use foreign keys, optimize lock table 7. Create index: 8. Optimize query statement

18. What are transactions in the database?

A transaction is an ordered set of database operations as a unit. A transaction is considered successful if all operations in the group succeed, even if only one operation fails, the transaction is not successful. If all operations are completed, the transaction is committed and its modifications are applied to all other database processes. If an operation fails, the transaction is rolled back and the effects of all operations in the transaction are canceled.

19. How to modify the survival time of SESSION

Method 1: Set session.gc_maxlifetime in php.ini to 9999 and restart apache

Method 2: $savePath = "./session_save_dir/"; $lifeTime = hours * seconds;

session_save_path($savePath);

session_set_cookie_params($lifeTime); session_start();

Method 3: setcookie() and session_set_cookie_params($lifeTime);

20.There is a web page address, such as the homepage of the PHP Development Resource Network: http://www.phpres.com/index.html, how to get its content?

Method 1 (for PHP5 and above): $readcontents = fopen("http://www.phpres.com/index.html", "rb"); $contents = stream_get_contents($readcontents); fclose($readcontents); echo $contents; Method 2: echo file_get_contents("http://www.phpres.com/index.html"); 21. Talk about the advantages and disadvantages of asp, php and jsp ASP's full name is Active Server Pages, which is a WEB server-side development environment that can be used to generate and run dynamic, interactive, high-performance WEB service applications. ASP uses the scripting language VB Script (Java script) as its own development language.
PHP is a cross-platform server-side embedded scripting language. It borrows a lot of syntax from C, Java and Perl languages, and couples PHP's own features to enable WEB developers to quickly write dynamically generated pages. It supports most current databases. Another point is that PHP is completely free, no money is required, and you can obtain the source code without restrictions, and you can even add the features you need.
JSP is a new generation website development language launched by Sun. It completely solves a common problem of current ASP and PHP - script-level execution. JSP can be powerful with the support of Serverlet and JavaBean.
All three provide the ability to mix certain program code in HTML code and have the language engine interpret and execute the program code. But the JSP code is compiled into a Servlet and interpreted and executed by the Java virtual machine. This compilation operation only occurs on the first request for the JSP page. In ASP, PHP, and JSP environments, HTML code is mainly responsible for describing the display style of information, while program code is used to describe processing logic. Ordinary HTML pages only rely on the Web server, while ASP, PHP, and JSP pages require additional language engines to analyze and execute program code. The execution results of the program code are re-embedded into the HTML code and then sent to the browser together. ASP, PHP, and JSP are all Web server-oriented technologies, and the client browser does not require any additional software support. 22. Please explain the difference between passing by value and passing by reference in PHP. When to pass value and when to pass reference? Pass by value: Any changes to the value within the scope of the function will be ignored outside the function Pass by reference: Any changes to the value within the scope of the function will also reflect these modifications outside the function Pros and Cons: When passing by value, php must copy the value. Especially for large strings and objects, this can be a costly operation. Passing by reference does not require copying the value, which is very good for improving performance. 23. What is the redirect function of JS? How to introduce an external JS file? window.location.href,fb558daa7ed135f0fcd07df3585f78852cacc6d41bbb37262a98f745aa00fbf0 24.What is the GD library used for? The gd library provides a series of APIs for processing images. You can use the GD library to process images or generate images. On websites, the GD library is usually used to generate thumbnails or to add watermarks to images or to generate reports on website data. ================================================== ==================================================
  1. Which version of PHP are we using?
  2. PHP What are the tags ?
  3. Include a closing ?> in a pure PHP file (for example, a file containing only a class definition) label, make sure it is not followed by any newline. Tell me your understanding.
  4. What are the methods for automatically loading classes?
  5. What are the similarities and differences between single quotes and double quotes?
  6. define() vs. Const ?
  7. There are multiple ways to configure a web server to provide PHP services. Which ones do you know?
  8. Purify HTML Input and output, how to deal with it?
  9. What do you know about UTF-8 in PHP?
  10. How does php handle date and time?
================================================== ================================================== 1. Write a function to implement the iterative operation of addition between each element in the array. Note: all array elements are natural numbers. Example: $data=array(1.2.3); The program requires printing out various possible additions of each array element to each other in the array (including the addition of the elements themselves) 1 1=2,1 2=3,1 3=4 ,2 2=4,2 3=5,3 3=6 2. A child bought candy worth less than $1 and handed the $1 to the salesperson. The salesperson hopes to give the child the change with the smallest number of coins. Assume that an unlimited number of coins with face values ​​of 25 cents, 10 cents, 5 cents, and 1 cent are provided. Write an algorithm to let the salesperson give the child the minimum number of coins. 3. There are 10 new employees, ranked from 1 to 10 according to their application performance, and 10 consecutive four-digit natural numbers are used as their job numbers. Each person's job number can be divisible by their performance ranking. What are their job numbers? ================================================== ================================================== 1. How to define variables? How to check if a variable is defined? How to delete a variable? Function to determine whether a variable is empty? isset() unset() empty() 2. What is a variable variable? The variable name of a variable can be set and used dynamically. $a = 'hello' , $$a = 'world', ${$a}=hello world 3. What are the methods of variable assignment? 1) Direct assignment 2) Assignment between variables 3) Reference assignment 4. What is the difference between quoting and copying? Copying is to copy the contents of the original variable. The copied variable and the original variable use their own memory and do not interfere with each other. Reference is equivalent to an alias of a variable, which actually means accessing the same variable content with different names. When you change the value of one variable, the other one also changes. 5. What are the basic data types of variables in php? php supports 8 primitive data types. Includes: four scalar types (Boolean, integer, float/double, string) Two composite types (array, object) Two special types (resource, NULL) 6. When other types are converted to boolean types, which ones are considered false? Boolean value false, integer value 0, floating point value 0.0, blank string, string '0', empty array, special data type NULL, no variable set. Under what circumstances does the empty() function return true? Boolean value false, integer value 0, floating point value 0.0, blank string, string '0', array() empty array, special data type NULL, object without any attributes, variable with no assigned value. 7. If a variable $a is defined but no initial value is assigned Does $a==0? $a==false? $a==''? $a==NULL? $a===NULL? Answer: echo=>Nothing, var_dump=>NULL empty($b)==true? ———————————— echo=>1 , var_dump=>bool(true) What is the output of $a at this time? ———————— echo=>Nothing, var_dump=>NULL What is the output of $a? —————————— echo=>1 , var_dump=>int(1) 8. How to convert a string into an integer? How many methods are there? How to achieve it? Forced type conversion: (integer) string variable name; direct conversion: settype (string variable, integer); intval (string variable); 9. What is the biggest difference between scalar data and arrays? A scalar can only store one data, while an array can store multiple data. 10. How are constants defined? How to check whether a constant is defined? What data types can the value of a constant be? define()//Define constant, defined()//Check whether the constant is defined. The value of a constant can only be scalar type data. 11. Constants are divided into system built-in constants and custom constants. Please name the most common system built-in constants? __FILE__ , __LINE__ , PHP_OS , PHP_VERSION 12. If two identical constants are defined, which one will work, the former or the latter? The former works because a constant cannot be redefined or undefined once defined. 13. What are the differences between constants and variables? 1) There is no $ sign before constants; 2) Constants can only be defined through define(), not assignment statements; 3) Constants can be defined and accessed anywhere, while variables are divided into global and local; 4 ) Once defined, constants cannot be redefined or undefined, while variables are redefined through assignment; 5) The value of a constant can only be scalar data, and the database type of a variable has 8 primitive data types. 14. What are the several predefined global array variables commonly used in PHP? There are 9 predefined built-in array variables: $_POST, $_GET, $_REQUEST, $_SESSION, $_COOKIE, $_FILES, $_SERVER, $_ENV, $GLOBALS 15. In actual development, where are constants most commonly used? 1) Define the information to connect to the database as constants, such as the user name, password, database name, host name of the database server; 2) Define part of the path of the site as constants, such as web Absolute path, installation path of smarty, folder path of model, view or controller; 3) Public information of the website, such as website name, website keywords and other information. 16. What are the advantages of functions? Improve the maintainability of the program, improve the reliability of the software, improve the reusability of the program, and improve the development efficiency of the program 17. How to define a function? Are function names case-sensitive? 1) Use the function keyword; 2) Function naming rules are the same as variables, starting with a letter or underscore, not a number; 3) Function names are not case-sensitive; 4) Function names cannot be used if they have been declared or the function name built by the system. 18. What is variable visibility or variable scope? is the scope of the variable in the program. According to the visibility of variables, variables are divided into local variables and global variables. 19. What are local variables and global variables? Can global variables be directly called within a function? Local variables are variables defined within a function, and their scope is the function in which they are located. If there is a variable with the same name as a local variable outside the function, the program will think that they are two completely different variables. When exiting the function, the local variables are cleared at the same time. Global variables are variables defined outside all functions. Their scope is the entire PHP file, but they cannot be used inside user-defined functions. If you must use global variables inside a user-defined function, you need to use the global keyword declaration. That is to say, if you add golbal before the variable in the function, then the global variable can be accessed inside the function. Not only can you use this global variable to perform operations, but you can also reassign the global variable. Global variables can also be called using $GLOBALS['var']. 20. How to use the global keyword? How to use the predefined global variable array $GLOBALS? Global is used to define global variables, but this global variable does not apply to the entire website, but to the current page, including all files in include or require.
In the $GLOBALS array, each variable is an element, the key name corresponds to the variable name, and the value corresponds to the content of the variable. $GLOBALS exists in the global scope because $GLOBALS is a superglobal variable. Global means that in a file, as long as you declare it as global $db, you can reference this $db below the declaration.
21. What are static variables? If a variable defined in a function is declared with the keyword static before it, then the variable is a static variable. Generally, after the function call ends, the data stored in the variables within the function will be cleared and the memory space occupied will be released. When using a static variable, the variable will be initialized when the function is called for the first time. After initialization, the variable will not be cleared. When the function is called again, the static variable will no longer be initialized, but can save the last time. The value after the function is executed. We can say that static variables are shared between all calls to the function. 22. What are the ways to pass parameters to functions in php? What's the difference between the two? Pass by value and pass by address (or pass by reference) (1) Pass by value: The variable to be passed is stored in a different space from the variable passed to the function. Therefore, modifications to the variable value within the function body do not affect the original variable value. (2) Pass by address: Use the & symbol to indicate that the parameter is passed by address. It does not pass the specified value or target variable in the main program to the function, but imports the memory storage block address of the value or variable into the function, so the variable in the function body and the variable in the main program are in the memory. are the same. Modifications made to the function body directly affect the value of the variable outside the function body. 23. What is a recursive function? How to make a recursive call? A recursive function is actually a function that calls itself, but it must meet the following two conditions: 1) Every time it calls itself, it must be closer to the final result; 2) There must be a definite recursion termination condition, which will not Create an infinite loop. 24. Determine whether a function exists? function_exists( string $function_name ) returns true if it exists, false if it does not exist. 25. What is the difference between func() and @func()? The second function call will not report an error if it fails, but the first one will report an error 26. What are the usage and differences between include() and require() functions? What about include_once() and require_once()? The error levels after errors occur in include and require are different. include_once() and require_once() need to determine whether they have been imported before loading 27. Tell me the difference between preposition and postposition? Prepositioning is to first increase the variable by 1, and then assign the value to the original variable; postpositioning is to first return the current value of the variable, and then increase the current value of the variable by 1. 28. What is the difference between the string operator "." and the arithmetic operator " "? When . is used between "a" and "b", it is considered a hyphen. If there is a difference between the two, php will consider it to be an operation. 1) If the strings on both sides of the number are composed of numbers, the string will be automatically converted to an integer; 2) If the strings on both sides of the number are pure letters, then 0 will be output; 3) If the strings on both sides of the number are composed of numbers , then the numbers at the beginning of the string will be intercepted and then operated. 29. What is the ternary (or ternary) operator? Choose between two expressions based on the result of one expression. For example: ($a==true) ? 'good':'bad'; 30. What are the control flow statements? 1: Three program structures sequential structure, branch structure, loop structure 2: branch: if/esle/esleif/ switch/case/default 3: switch Note: The constants in the case clause can be integers, String constants or constant expressions are not allowed to be variables. In the same switch clause, the case values ​​cannot be the same, otherwise only the value in the first occurrence of the case can be obtained. 4: The loop for while do...while do...while must be followed by a semicolon. The difference between while and do...while 5: The difference between break and continue. break can terminate the loop. continue is not as powerful as break. It can only terminate this loop and enter the next loop. 31. What is the concept of array? What are the two types of arrays based on indexes, and how to distinguish them? What are the two ways of assigning values ​​to an array? An array is a variable (composite variable) that can store a set or series of values. Index array (index value is a number, starting with 0) and associative array (with string as index value). What are the assignment methods of arrays? Two kinds? There are two main ways to declare arrays. 1. Declare the array through the array() function; you can define the index and value respectively through key=>value, or you can not define the index subscript of the array and only give the element value of the array. 2. Directly assign values ​​to array elements without calling the array() function. For example: $arr[0] = 1; $arr[1] = 2; Special note: If the subscript of the array is a string value equivalent to an integer (but cannot start with 0), it will be treated as an integer. . For example: $array[3] and $array['3'] refer to the same element, while $array['03'] refers to another element. 32. How to traverse an array? ①for loop ②foreach loop The usage is as follows: foreach($arr as $key=>$value){} ③list each and while are combined to loop 33. How does the pointer point when foeach array? How does the pointer point when list()/each()/while() loops through the array? When foreach starts executing, the pointer inside the array will automatically point to the first unit. Because foreach operates on a copy of the specified array, not the array itself. After each() an array, the array pointer will stay at the next unit in the array or at the last unit when it reaches the end of the array. If you want to use each() to traverse the array again, you must use reset(). reset() rewinds the internal pointer of the array to the first unit and returns the value of the first array unit. 34. How to calculate the length of an array (or count the number of all elements in the array)? How to get the length of a string? count() -- Count the number of elements in the array. You can use count (array name) or count (array name, 1). If there is a second parameter and it is the number 1, it means recursively counting the number of array elements. If the second parameter is the number 0, it is equivalent to the count() function with only one parameter. sizeof() -- alias of count() String: strlen(), mb_strlen(); 35. What are the common functions related to arrays? 1) count -- (sizeof alias) - Calculate the number of cells in the array or the number of attributes in the object. For example: int count (mixed $var [, int $mode]) $var is usually an array type, any All other types have only one unit. The default value of $mode is 0. 1 turns on recursively counting the array 2) in_array (mixed $needle, array $haystack [, bool $strict]) — Check whether a certain value exists in the array. If needle is a string, the comparison is case-sensitive. If the value of the third parameter strict is TRUE, the in_array() function will also check whether the type of needle is the same as that in haystack. 3) array_merge(array $array1 [, array $array2 [, array $... ]] ) merges the cells of one or more arrays, and the values ​​in one array are appended to the previous array. Returns the resulting array. Special note: If the input array has the same string key name, the value after the key name will overwrite the previous value. However, if the array contains numeric keys, the subsequent values ​​will not overwrite the original values, but will be appended to them. If only one array is given and the array is numerically indexed, the key names will be re-indexed in a continuous manner 4) Conversion between array and string (1)explode ( string $separator , string $string [, int $limit ] ) Separates a string using a delimiter character. (2)implode ( string $glue , array $arr ) uses a connector to connect each unit in the array into a string. join is an alias of implode 5) sort(array &$array [, int $sort_flags]) — Sort the array by value. When this function ends, the array cells will be rearranged from lowest to highest. 36. What is the difference between the array merging function array_merge() and the array addition operation $arr $arr2? array_merge()-> Use array_merge(). If it is an associative array merge, if the key names of the arrays are the same, the later values ​​will overwrite the former; if it is a numeric index array merge, it will not be overwritten, but the latter. appended to the former. " "->Use array addition operation, which is different from array_merge(). Whether the addition operation is an associative array or a numerical index array, the values ​​​​with the same key name are discarded, that is, only the element in which the key name appears for the first time is retained. Subsequent elements with the same key name will not be added. 37. What is the difference between single quotes and double quotes when defining strings? ” ” Fields enclosed in double quotes will be interpreted by the compiler and then output as HTML code.
‘ ‘ The words in the single quotes are not interpreted and are output directly.
38. What are the differences between echo(), print() and print_r()? (1)echo is syntax, Output one or more strings, no return value; (2)print is a function, cannot output arrays and objects, Output a string, print has a return value; (3)print_r is a function, can Output array. print_r is an interesting function. It can output string, int, float, array, object, etc. When outputting array, it will be represented by a structure. print_r returns true when the output is successful; and print_r can be passed print_r($str,true), so that print_r Returns the value processed by print_r without outputting it. In addition, for echo and print, echo is basically used because its efficiency is higher than print. ================================================== ================================================== 39. What are the string processing functions according to functional classification? What do these functions do? A. String output function (1)echo $a,$b,$c...; is a language structure, not a real function. (2)print($a) This function outputs a string. Returns 1 if successful, 0 if failed (3)print_r($a) (4)var_dump($a); can output type, length, value B. Function to remove spaces at the beginning and end of a string: trim ltrim rtrim (alias: chop ) Using the second parameter, you can also remove the specified characters. C. Escape string function: addslashes() D. Get string length function: strlen() E. Intercept string length function: substr() F. Retrieve string function: strstr(), strpos() G. Replace string function: str_replace() 40. Please give the correct answers to the following questions? 1).$arr = array('james', 'tom', 'symfony'); Please split the value of the $arr array with ',' and merge it into a string for output? echo implode(‘,’,$arr); 2).$str = ‘jack,james,tom,symfony’; Please split $str with ‘,’ and put the split value into the $arr array? $arr = explode(',',$str); 3).$arr = array(3,7,2,1,'d','abc'); Please sort $arr from large to small , and keep its key values ​​unchanged? arsort($arr); print_r($arr); 4).$mail = “gaofei@163.com”; Please take out the domain of this mailbox (163.com) and print it to see how many methods you can write. ? echo strstr($mail,'163'); echo substr($mail,7); $arr = explode("@",$mail); echo $arr[1]; 5). If there is a string, the The string is "123, 234, 345,". How can I cut off the last comma in this string? 6). What are the functions for obtaining random numbers? Which execution speed is faster, mt_rand() or rand()? 41. The characters on the page are garbled, how to solve it? 1. First consider whether the current file has a character set set. Check whether charset is written in the meta tag. If it is a PHP page, you can also check whether charset is specified in the header() function; For example: 5d4fd62a4f58da8b666a698127081f22 header("content-type:text/html;charset=utf-8"); 2. If the character set (that is, charset) is set, then determine the encoding format of the current file saved Whether it is consistent with the character set set on the page, the two must be unified; 3. If it involves extracting data from the database, then determine whether the character set when querying the database is consistent with the character set set on the current page, the two must be unified, for example :mysql_query("set names utf8"). 42. What is a regular expression? What are the commonly used functions related to regular expressions in PHP? Please write a regular expression for email, Chinese mobile phone number and landline number? Regular expression is a grammatical rule used to describe character arrangement patterns. Regular expressions are also called pattern expressions. In website development, regular expressions are most commonly used for client-side validation before form submission information. For example, verify whether the user name is entered correctly, whether the password input meets the requirements, and whether the input of email, mobile phone number and other information is legal. In PHP, regular expressions are mainly used for string splitting, matching, search and replacement operations. The preg series of functions can handle it. The specific ones are as follows: string preg_quote ( string str [, string delimiter] ) Escape regular expression characters. Special characters of regular expressions include: . \ * ? [ ^ ] $ ( ) { } = ! 6d267e5fab17ea8bc578f9e7e5e1570b | :. preg_replace -- perform regular expression search and replace mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] ) preg_replace_callback -- use callback function to perform regular expression search and replace mixed preg_replace_callback ( mixed pattern, callback callback , mixed subject [, int limit] ) preg_split - Split a string array with a regular expression preg_split ( string pattern, string subject [, int limit [, int flags]] ) 43. Which function should be used if you want to filter out all html tags in a certain string? It seems to be using the strip_tags function
44. What are the differences in the use of preg_replace() and str_ireplace()? How to use preg_split() and split() functions? str_replace: This should be the preferred method for string replacement, but there is one thing to note, that is, put the element you most want to match in front.
strtr: strtr is also very efficient when replacing short strings. However, the difference in the subscript length of the search array also has a greater impact on efficiency. Also, it is best not to use it if nothing happens. This form is strtr(string, string, string) (garbled characters are easily produced for non-single-byte characters).
preg_replace: Needless to say, you can use regular matching, which is definitely the most powerful function, but you have to sacrifice some efficiency.

45. What are the main functions for obtaining the current timestamp? Use PHP to print out today's time in the format of 2010-12-10 22:21:21? Use PHP to print out the time of the previous day in the format of 2010-12-10 22:21:21? How to turn 2010-12-25 10:30:25 into a unix timestamp? echo date ("Y-m-d H:i:s" ,strtotime('-1,days')); date('Y-m-d H:i:s',time()); $unix_time = strtotime("2009- 9-2 10:30:25");//Change to unix timestamp echo date("Y-m-d H:i:s",$unix_time);//Format to normal time format 46. When using get to pass values ​​in the URL, if the Chinese characters appear garbled, which function should be used to encode the Chinese characters? When the user submits data in the website form, in order to prevent script attacks (for example, the user inputs 3f1c4e4b6b16bbbd69b2ee476dc4f83aalert (111); 2cacc6d41bbb37262a98f745aa00fbf0), how should the PHP side handle the data when it receives it? Use urlencode() to encode Chinese and urldecode() to decode. Use htmlspecialchars($_POST[‘title’]) to filter form parameters to avoid script attacks. 47. What are the steps to connect to the database? What data type is the return value of each step? In particular, what data type does mysql_query() return?

$conn=mysql_pconnect("localhost","root","123456");//Open the connection
mysql_select_db("database name",$conn);//Connect to the specified database
mysql_query("set names utf8");//Set character encoding
$sql="";
$R=mysql_query($sql);//Execute SQL statements and return the result set
while( $v=mysql_fetch_array($R)){
echo "field name".$v['title'];
}

mysql_query() If it contains statements such as queries, it will return resources. To put it bluntly, it is the data result set you want to check; if it contains statements such as additions, deletions, and modifications, it will return true or false. 48. What are the differences between mysql_fetch_row() and mysql_fetch_assoc() and mysql_fetch_array? The first one returns a row in the result set as an index array, the second one returns an associative array, and the third one can return either an index array or an associative array, depending on its second parameter MYSQL_BOTH MYSQL_NUM MYSQL_ASSOC The default is MYSQL_BOTH $sql = "select * from table1"; $result = mysql_query($sql); mysql_fetch_array($result, MYSQL_NUM); 49. Please tell me the functions you have learned so far that return resources? Answer: mysql_connect(); mysql_query(); Only when the select is successful, the resource will be returned. If it fails, it will return FALSE fopen(); 50. Slightly 51. What details should be paid attention to when uploading files? How to save files to a specified directory? How to avoid the problem of uploading files with duplicate names? 1. First, you need to enable file upload in php.ini; 2. There is a maximum allowed upload value in php.ini, the default is 2MB. You can change it when necessary; 3. When uploading a form, be sure to write enctype="multipart/form-data" in the form tag; 4. The submission method must be post; 5. Set the form with type="file" Control; 6. Pay attention to whether the size of the uploaded file MAX_FILE_SIZE, the file type meets the requirements, and whether the path where it is stored after uploading exists. You can get the file suffix from the uploaded file name, and then rename the file using the timestamp file suffix, thus avoiding duplicate names. You can set the saving directory of the uploaded file yourself, and combine it with the file name to form a file path. Use move_uploaded_file() to save the file to the specified directory. 52. How many dimensions is $_FILES? What are the index subscripts for the first and second dimensions? What should I pay attention to when uploading files in batches? Two-dimensional array. The first dimension is the name of the upload control, and the two-dimensional subscripts are name/type/tmp_name/size/error. 53. What are the main functions of the header() function? What should you pay attention to during use? Use the header function to jump to the page, header('Location:'.$url); use header to declare content-type, header('content-type:text/HTML;charset=utf-8′); use header Return the response status code, for example: header('HTTP/1.1 404 Not Found'); use the header to perform a jump after a certain time, header("Refresh: {$delay}; url={$url}"), where $delay is to delay the jump, $url is the URL that needs to be jumped; use header to control browser cache; perform http verification, header('HTTP/1.1 401 Unauthorized'), header('WWW-Authenticate: Basic realm= "Top Secret"'); Use header for download operation;
54. How to use the header() function when downloading files? header("content-type: application/octet-stream;charset=UTF-8"); //What is the difference between adding utf-8 here and defining it above? header("accept-ranges: bytes"); header("accept-length: ".filesize($filedir.$filename)); header("content-disposition: attachment; filename=".$filedir.$ filename); 55. What is ajax? What is the principle of ajax? What is the core technology of ajax? What are the advantages and disadvantages of ajax? ajax is the abbreviation of asynchronous javascript and xml, which is a combination of javascript, xml, css, DOM and other technologies. '$' is an alias of jQuery. The user's request in the page communicates with the server asynchronously through the ajax engine. The server returns the request result to the ajax engine. Finally, the ajax engine decides to display the returned data on the page. Specify location. Ajax finally enables loading all the output content of another page at a specified location on one page. In this way, a static page can also obtain the returned data information from the database. Therefore, ajax technology enables a static web page to communicate with the server without refreshing the entire page, reducing user waiting time, thereby reducing network traffic and enhancing the friendliness of the customer experience. The advantages of Ajax are: 1. Reduces the burden on the server, transfers part of the work previously burdened by the server to the client, and uses the client's idle resources for processing; 2. Updates the page with only partial refresh, which increases The page response speed makes the user experience more friendly. The disadvantage of Ajax is that it is not conducive to SEO promotion and optimization, because search engines cannot directly access the content requested by Ajax. The core technology of ajax is XMLHttpRequest, which is an object in javascript. 56. What is jquery? What are the ways to simplify ajax in jquery? jQuery is a framework for Javascript. $.get(),$.post(),$.ajax(). $ is an alias for jQuery object. The code is as follows: $.post(url address for asynchronous access, {'parameter name': parameter value}, function(msg){ $("#result").html(msg); }); $.get (URL address for asynchronous access, {'parameter name': parameter value}, function(msg){ $("#result").html(msg); }); $.ajax({ type: "post", url : loadUrl, cache:false, data: "Parameter name=" parameter value, success: function(msg) { $("#result").html(msg); } }); 57. What is session control? Simply put, session control is a mechanism for tracking and identifying user information. The idea of ​​session control is to be able to track a variable in the website. Through this variable, the system can identify the corresponding user information. Based on this user information, the user permissions can be known, so as to display the page content suitable for the user's corresponding permissions. Currently, the most important session tracking methods include cookies and sessions. 58. Basic steps of session tracking 1). Access the session object related to the current request 2). Find information related to the session 3). Store session information 4). Discard session data 59. What are the precautions for using cookies? 1) There cannot be any page output before setcookie(), even spaces and blank lines are not allowed; 2) After setcookie(), calling $_COOKIE['cookiename'] on the current page will not produce any output and must be refreshed Or you can't see the cookie value until you go to the next page; 3) Different browsers handle cookies differently. The client can disable cookies, and the browser can also idle the number of cookies. A browser can create up to 300 cookies. And each cannot exceed 4kb, and the total number of cookies that can be set by each website cannot exceed 20. 4) Cookies are stored on the client side. If the user disables cookies, setcookie will not work. So don't rely too much on cookies. 60. When using session, what is used to represent the current user to distinguish it from other users? sessionid, the current session_id can be obtained through the session_id() function. 61. What are the steps for using session and cookie? What is the life cycle of session and cookie? What is the difference between session and cookie? Cookies are stored on the client machine. For cookies with no expiration time set, the cookie value will be stored in the machine's memory. As long as the browser is closed, the cookie will disappear automatically. If the cookie expiration time is set, the browser will save the cookie to the hard disk in the form of a text file, and the cookie value will still be valid when the browser is opened again. The session saves the information that the user needs to store on the server side. Each user's session information is stored on the server side like a key-value pair, where the key is the sessionid and the value is the information the user needs to store. The server uses sessionid to distinguish which user the stored session information belongs to. The biggest difference between the two is that the session is stored on the server side, while the cookie is stored on the client side. Session security is higher, while cookie security is weak. Sessions play a very important role in web development.It can record the user's correct login information into the server's memory. When the user accesses the management backend of the website with this identity, the user can get identity confirmation without logging in again. Users who have not logged in correctly will not be allocated session space, and will not be able to see the page content even if they enter the access address of the management background. The user's operation permissions on the page are determined through the session. Steps to use session: 1. Start session: Use session_start() function to start. 2. Register session: Just add elements to the $_SESSION array directly. 3. Use session: Determine whether the session is empty or registered. If it already exists, use it like an ordinary array. 4. Delete a session: 1. You can use unset to delete a single session; 2. Use $_SESSION=array() to log out all session variables at once; 3. Use the session_destroy() function to completely destroy the session. How are cookies used? 1. Record part of the information visited by the user 2. Pass variables between pages 3. Store the viewed Internet page in the cookies temporary folder, which can improve future browsing speed. Create a cookie: setcookie(string cookiename, string value, int expire); Read cookies: Read the value of the cookie on the browser side through the super global array $_COOKIE. Delete cookies: There are two methods 1. Manual deletion method: Right-click the browser properties, you can see Delete cookies, perform the operation to delete all cookie files. 2.setcookie() method: The same as the method of setting cookies, but this time the cookie value is set to empty, and the valid time is 0 or less than the current timestamp. ================================================== ================================================== 62. How to set the name of a cookie to username, the value to jack, and make the cookie expire after one week? How many cookies can a browser generate at most, and what is the maximum size of each cookie file? setcookie(‘username’,’jack’,time() 7*24*3600); can generate up to 20 cookies, each of which cannot exceed 4K 63. What needs to be done before setting or reading session? You can directly enable session.auto_start = 1 in php.ini or use session_start() at the head of the page; to open the session, there must be no output before session_start(), including blank lines. 64. In actual development, in what situations is session used? Session is used to store user login information and pass values ​​across pages. 1) Commonly used to assign user login information to the session after the user successfully logs in; 2) Used to generate verification code images, and assign the value to the session after the random code is generated. 65. How many ways are there to log out of a session? unset() $_SESSION=array(); session_destroy(); 66. What is OOP? What are classes and objects? What are class attributes? OOP (object oriented programming), which is object-oriented programming, the two most important concepts are classes and objects. The collection of attributes and methods forms a class. Classes are the core and foundation of object-oriented programming. Through classes, scattered codes used to implement a certain function are effectively managed. A class is just an abstract model with certain functions and attributes, but actual applications require entities one by one, that is, the class needs to be instantiated. After instantiation, the class becomes an object. A class is an abstract concept of an object, and an object is an instantiation of a class. OOP has three major characteristics: 1. Encapsulation (also called hiding); 2. Inheritance; 3. Polymorphism. Advantages of OOP: 1. High code reusability (code saving) 2. High program maintainability (scalability) 3. Flexibility 67. What are the commonly used access modifiers of attributes? What do they mean? private, protected, public. Outside the class: public, var In the subclass: public, protected, var In this class: private, protected, public, var If you do not use these three keywords, you can also use the var keyword. But var cannot be used with permission modifiers. Variables defined by var can be accessed in subclasses and can also be accessed outside the class, which is equivalent to public. In front of the class: only final and abstract can be added. In front of the attribute: there must be access modifiers (private, protected, public, var) , in front of the method: static, final, private, protected, public, abstract 68. What do the three keywords $this and self and parent represent respectively? In what situations is it used? $this is the current object, self is the current class, parent is the parent class of the current class, $this is used in the current class, use -> to call properties and methods. self is also used in the current class, but it needs to be called using ::. parent is used in classes. 69. How to define constants in a class, how to call constants in a class, and how to call constants outside a class. Constants in a class are also member constants. A constant is a quantity that does not change and is a constant value. To define constants, use the keyword const. For example: const PI = 3.1415326; Whether inside a class or outside a class, access to constants is different from variables. Constants do not need to instantiate objects. The format for accessing constants is the class name plus scope. Operator symbol (double colon) to call.That is: class name :: class constant name; 70. Scope operator::How to use? In what situations is it used? Call class constants and static methods. 71. What is a magic method? What are some commonly used magic methods? System-customized methods starting with __. __construct() __destruct() __autoload() __call() __tostring() 72. What are constructors and destructors? Constructor method is a member method that is automatically executed when instantiating an object. Its function is to initialize the object. Before php5, a method with the same name as the class is a constructor method. After php5, the magic method __construct() is a constructor method. If there is no constructor defined in the class, PHP will automatically generate one. This automatically generated constructor has no parameters and no operations. The role of the destructor method is exactly the opposite of the constructor method. It is automatically called when the object is destroyed, and its role is to release memory. The destructor method is defined as: __destruct(); Because PHP has a garbage collection mechanism that can automatically clear objects that are no longer used and release memory. Generally, you do not need to manually create a destructor method. 73. How does the __autoload() method work? The basic condition for using this magic function is that the file name of the class file must be consistent with the name of the class. When the program is executed to instantiate a certain class, if the class file is not introduced before instantiation, the __autoload() function is automatically executed. This function will search for the path of this class file based on the name of the instantiated class. When it is determined that this class file does exist in the path of this class file, it will execute include or require to load the class, and then the program will continue to execute. If this path If the file does not exist, an error will appear. Using the autoloading magic function eliminates the need to write many include or require functions. 74. What are abstract classes and interfaces? What are the differences and similarities between abstract classes and interfaces? An abstract class is a class that cannot be instantiated and can only be used as a parent class of other classes. Abstract classes are declared using the keyword abstract. Abstract classes are similar to ordinary classes in that they contain member variables and member methods. The difference between the two is that an abstract class must contain at least one abstract method. An abstract method has no method body, and this method is inherently to be overridden by subclasses. The format of the abstract method is: abstract function abstractMethod(); Because PHP only supports single inheritance, if you want to implement multiple inheritance, you must use an interface. In other words, subclasses can implement multiple interfaces. The interface is declared through the interface keyword. The member variables and methods in the interface are public. The method does not need to write the keyword public. The methods in the interface also have no method body. The methods in the interface are also inherently intended to be implemented by subclasses. The functions implemented by abstract classes and interfaces are very similar. The biggest difference is that interfaces can implement multiple inheritance. The choice between abstract class or interface in an application depends on the specific implementation. Subclasses inherit abstract classes using extends, and subclasses implement interfaces using implements. Does an abstract class have at least one abstract method? Answer: If a class is declared as an abstract class, it does not need to have abstract methods. If there is an abstract method in a class, the class must be an abstract class 75. How many parameters are there in __call, what are their types, and what are their meanings? The function of the magic method __call() is that when the program calls a non-existent or invisible member method, PHP will first call the __call() method and store the method name and parameters of the non-existent method. __call() contains two parameters. The first parameter is the method name of the non-existent method, which is a string type; the second parameter is all the parameters of the non-existent method, which is an array type. I think the __call() method is more about debugging and can locate errors. At the same time, exceptions can be caught. If a method does not exist, other alternative methods will be executed. 76. What is the use of smarty template technology? In order to separate php and html, artists and programmers should perform their own duties without interfering with each other. 77.What are the main configurations of smarty? 1. Introduce smarty.class.php; 2. Instantiate the smarty object; 3. Re-modify the default template path; 4. Re-modify the default compiled file path; 5. Re-modify the default configuration file path ;6. Re-modify the default cache path. 7. You can set whether to enable cache. 8. You can set left and right delimiters. 78. What details do you need to pay attention to when using smarty? Smarty is a template engine based on the MVC concept. It divides a page program into two parts for implementation: the view layer and the control layer. In other words, smarty technology separates the user UI from the PHP code. In this way, programmers and artists perform their respective duties without interfering with each other. When using smarty, you should pay attention to the following issues: 1. Configure smarty correctly. It is mainly necessary to instantiate the smarty object and configure the path of the smarty template file; 2. Use assign assignment and display to display the page in the php page; 3. PHP code segments are not allowed in the smarty template file, and all comments, variables, and functions must be included within the delimiter.A.{} B. foreach C. if else D. include E. literal 79. What is the concept of MVC? What are the main tasks of each level? MVC (Model-View-Controller) is a software design pattern or programming idea. M refers to the Model layer, V is the View layer (display layer or user interface), and C is the Controller layer. The purpose of using mvc is to separate M and V so that one program can easily use different user interfaces. In website development, the model layer is generally responsible for adding, deleting, modifying, and checking database table information. The view layer is responsible for displaying page content. The controller layer plays a regulating role between M and V. The controller layer decides which method of which model class to call. , after the execution is completed, the controller layer decides which view layer the result will be assigned to. 80. Slightly 81. What do method rewriting and overloading mean in Java language? To be precise, does PHP support method overloading? How to actually understand the PHP overloading mentioned in many reference books correctly? PHP does not support method overloading. The PHP ‘overloading’ mentioned in many books should be ‘rewriting’ 82. Can the final keyword define member attributes in a class? No, class member attributes can only be defined by public, private, protected, var 83. Can classes defined by the final keyword be inherited? Classes defined by final cannot be inherited 84. Tell me about the use cases of static keyword? Can static be used before class? Can static be used together with public, protected, and private? Can a constructor be static? static can be used in front of attributes and methods. When calling static attributes or methods, it is available as long as the class is loaded without instantiation. Static cannot be used in front of class. static can be used together with public, protected, and private, in front of the method; the constructor cannot be static 85. Can interfaces be instantiated? Can abstract classes be instantiated? Answer: Neither interfaces nor abstract classes can be instantiated 86. Can access modifiers be added in front of class? If it can be added, which access modifiers can it be? Can it be the permission access modifier public, protected, private? Final and static can be added in front of class; public, protected, and private cannot be added in front of class 87. Can there be no access modifier before the attributes in the class? Can the modifiers before member variables only be public, protected, or private? Which other ones could it be? The attributes in the class must be added with modifiers. In addition to those 3, you can also add var 88. If you echo an array, what will the page output? What about echoing an object? What about printing an array or object? The page can only output "Array"; echoing an object will cause an error message. When printing an array, it only outputs "Array". When printing an object, an error message appears. Print and echo are the same 89. When is the __tostring() magic method automatically executed? Does the __tostring() magic method have to return a return value? When echo or print an object, it is automatically triggered. And __tostring() must return a value 90. What is an abstract method? There is abstract in front of the method, and the method has no method body, not even "{ }" 91. If a method in a class is an abstract method, but the class is not defined as an abstract class, will an error be reported? Yes, "Fatal error: Class t2 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (t2::ee) in" 92. If a class is an abstract class and the methods in the class are non-abstract methods, will an error be reported? No, if a class is an abstract class, it does not need to have an abstract method, but there is an abstract method in a class, then this class must be an abstract class 93. slightly 94. What issues should be paid attention to when applying the final keyword? Classes defined using the final keyword are prohibited from inheritance. Methods defined using the final keyword are prohibited from overriding. 95. If a class wants to inherit a parent class and implement multiple interfaces, how should it be written? Writing format such as: class MaleHuman extends Human implements Animal,Life { ... } ================================================== ================================================== 96. What is single point of entry?         The so-called single point of entry means that there is only one entrance for the entire application, and all implementations are forwarded through this entrance. For example, above we use index.php as the single point of entry for the program. Of course, this can be arbitrarily done by you. controlled. There are several advantages to a single point of entry: First, some variables, classes, and methods processed globally by the system can be processed here. For example, you need to perform preliminary filtering of data, you need to simulate session processing, you need to define some global variables, and you even need to register some objects or variables into the register. Second, the program structure is clearer. 97. PHP provides 2 sets of regular expression function libraries, which ones are they? (1) PCRE Perl compatible regular expression: preg_ is the prefix (2) POSIX Portable operating system interface: ereg_ is the prefix 98. What is the composition of regular expressions? consists of atoms (ordinary characters, such as English characters), metacharacters (characters with special functions), and pattern correction characters. A regular expression contains at least one atom 99. What is the triggering time for uncommon magic methods? __isset() The triggering timing of __unset() __sleep() and __wakeup() are called when serializing the object. If the __sleep() method is not written when serializing the object, all members Attributes will be serialized, and if the __sleep() method is defined, only the variables in the specified array will be serialized.
Statement:
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