I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial

WBOY
Release: 2016-07-13 10:18:40
Original
955 people have browsed it

Compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineers

1. Basic knowledge points

. . .

  • The difference between Include require include_once require_once.
  • The evolutionary history of several versions of PHP/Mysql, such as major improvements from mysql4.0 to 4.1, PHP 4.x to 5.1, etc.
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. MySQL:
    2. 1. Main changes from 4.0 to 4.1
    3. If an InnoDB table containing a TIMESTAMP field was created in MySQL versions 4.1.0 to 4.1.3. Then you need to rebuild the table when upgrading to 4.1.4 and higher because the storage format has changed.
    4. Strings are compared according to standard SQL: trailing spaces are not removed before comparison, and shorter strings were previously extended with trailing spaces. The current result is
    5. 'a' > 'at', this was not the case before. You can use mysqlcheck to check the data table.
    6. TIMESTAMP returns a string in the format of 'YYYY-MM-DD HH:MM:SS'. In MySQL 4.0, you can add the option --new to get this feature in ySQL 4.1.
    7. Before MySQL 4.1.1, the statement parser was not so strict. It would ignore other characters before the first number when processing string to time conversion. After 4.1.1, it is more strict. The result of a function whose return result is DATE, DATETIME, or TIME type will be converted into time type
    8. 2. Let’s look at the main changes from 4.1 to 5.0
    9. ◆The index order of TEXT fields ending in spaces in InnoDB and MyISAM tables has changed. Therefore, you need to run the "CHECK TABLE" statement to repair the data table. If an error occurs, run the "OPTIMIZE TABLE" or "REPAIR TABLE" statement to repair it, or even re-dump it (using mysqldump).
    10. ◆Starting from MySQL 5.0.15, how to handle the value filled in the BINARY field has changed. The padded value is now 0x00 instead of spaces, and the trailing spaces will not be removed when retrieving the value.
    11. ◆Starting from MySQL 5.0.3, the implementation of DECIMAL has changed. 5.0 has much stricter format restrictions on DECIMAL. DECIMAL fields created in MyISAM and InnoDB tables between MySQL 5.0.3 and 5.0.5 will crash after upgrading to 5.0.6. Starting with 5.0.3, DECIMAL is stored in a more efficient format. Starting in 5.0.3, exact math is used when calculating DECIMAL values ​​and rounding exact values.
    12. ◆In the past, waiting for a timeout lock would cause InnoDB to roll back all current transactions. Starting from 5.0.13, only the most recent SQL statement will be rolled back.
    13. ◆Before 4.1.13/5.0.8, DATETIME was converted into YYYYMMDDHHMMSS format after adding 0, and now it is in YYYYMMDDHHMMSS.000000 format
    14. ◆In 4.1, the comparison between FLOAT or DOUBLE happens to be fine, but it may not work in 5.0
    15. ◆ Starting from 5.0.3, the spaces at the end of VARCHAR and VARBINARY fields are no longer deleted
    16. ◆ Added a new startup option innodb_table_locks, which causes InnoDB table locks to be requested when LOCK TABLE. This option is enabled by default, but may cause deadlock in AUTOCOMMIT=1 and LOCK TABLES applications. It seems that I only need to focus on the two types of changes: time (TIMESTAMP, DATETIMEDATE, TIME) and numeric type (FLOAD, DOUBLE, DECIMAL); in addition, I do not need to involve it in the upgrade process yet. Character set issues, so it's relatively easy.
    17. Upgrade steps are as follows:
    18. Execute
    19. FLUSH TABLES WITH READ LOCK;
    20. Directly copy the MyISAM table file
    21. Use mysqldump to export Innodb type tables
    22. The whole process went smoothly. After the new system was started, the following 2 problems were discovered:
    23. The keyword INOUT has been added, so you need to check what other fields in the table structure use the keyword
    24. DATE_FORMAT function has much stricter requirements,
    25. DATE_FORMAT('2006/11/24 09:14:00', '%Y-%m-%d %T')
    26. and DATE_FORMAT('2006/11/2409:14:00', '%Y-%m-%d %T')
    27. The results of
    28. are completely different. In 4.0, these two formats are compatible, but in 5.0, you can only use the former correctly, and the latter will have problems. This should also be caused by the change in time type mentioned above.
    PHP: Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. The following improvements in PHP5 are worthy of attention:
    2. 1. Greatly improved object-oriented capabilities;
    3. 2. Support try/catch exception handling;
    4. 3. Improved string processing;
    5. 4. Improved xml and web service support;
    6. 5. Built-in support for SQlite.
  • HEREDOC introduction
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. Heredoc technology is generally not described in detail in formal PHP documents and technical books. It is only mentioned that it is a Perl-style string output technology. However, some current forum programs and some article systems cleverly use heredoc technology to partially realize the quasi-separation of interface and code. The phpwind template is a typical example.
    2. 1. Start with the End start tag and end with the End end tag. The end tag must be written at the top, without indentation or spaces, and there must be a break at the end of the end tag. Number . The start tag is the same as the start tag. For example, it is commonly represented by capital letters EOT, EOD, and EOF, but it is not limited to those few. Just make sure that the start tag and the end tag do not appear in the text.
    3. 2. Variables located between the start tag and the end tag can be parsed normally, but functions cannot. In heredoc, variables do not need to be spliced ​​with connectors. or,, as follows:
    4. $v=2;
    5. $a=
    6. "abc"$v
    7. "123"
    8. EOF;
    9. echo $a; //The result is output together with double quotes: "abc"2 "123"
    10. 3. heredoc is often used when outputting documents containing a large number of HTML syntax. For example: the function outputhtml() should output the HTML home page. There are two ways to write it. Obviously the second way of writing is simpler and easier to read.
    11. function outputhtml(){
    12. echo "";
    13. echo "Homepage"; 
    14. echo "Homepage content";
    15. echo ";
    16. }
    17. function outputhtml()
    18. {
    19. echo
    20. Homepage
    21. Homepage content
    22. EOT;
    23. }
    24. outputhtml();
    25. The $ variable will be automatically replaced in heredoc, and the command and input will be put together for convenience
  • Write some php magic methods;
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. PHP stipulates that methods starting with two underscores (__) are reserved as magic methods, so it is recommended that your function name should not start with __ unless it is to overload an existing magic method.
    2. The magic methods in PHP are: __construct, __destruct, __call, __callStatic,__get, __set, __isset, __unset, __sleep, __wakeup, __toString, __set_state, __clone, __autoload
    3. 1, __get, __set
    4. These two methods are designed for properties that are not declared in the class and their parent class
    5. __get( $property ) This method will be triggered when an undefined property is called, and the parameter passed is the name of the property being accessed
    6. __set( $property, $value ) When assigning a value to an undefined property, this method will be triggered. The parameters passed are the set property name and value
    7. The non-declaration here includes attributes whose access control is protected and private (that is, attributes that have no permission to access) when called using an object.
    8. 2, __isset, __unset
    9. __isset( $property ) This method is called when the isset() function is called on an undefined property
    10. __unset( $property ) This method is called when the unset() function is called on an undefined property
    11. The same as the __get method and __set method. The no declaration here includes when using an object call, the access control is protected, private attributes (that is, attributes without permission to access)
    12. 3.__call
    13. __call( $method, $arg_array ) This method is called when calling an undefined method
    14. The undefined methods here include methods that do not have permission to access; if the method does not exist, go to the parent class to find the method. If it does not exist in the parent class, call the __call() method of this class. If the __call() method does not exist in this class, go to the __call() method in the parent class
    15. 4.__autoload
    16. __autoload function, which is automatically called when trying to use a class that has not been defined yet. By calling this function, the scripting engine has a last chance to load the required classes before PHP fails with an error.
    17. If you want to define a global autoloading class, you must use the spl_autoload_register() method to register the processing class to the PHP standard library:
    18. view plaincopy to clipboardprint?
    19. class Loader
    20. static function autoload_class($class_name)
    21. //Look for the correct $class_name class and introduce it, if not, an exception will be thrown
    22. /**
    23. * Set up automatic loading of objects
    24. * spl_autoload_register — Register given function as __autoload() implementation
    25. */ 
    26. spl_autoload_register(array('Loader', 'autoload_class'));
    27. $a =
    28. new Test();
    29. //Test is instantiated without require to achieve automatic loading. Many frameworks use this method to automatically load classes
    30. ?> 
    31. Note: Exceptions thrown in the __autoload function cannot be caught by the catch statement block and cause fatal errors, so they should be caught in the function itself.
    32. 5. __construct, __destruct
    33. __construct constructor, this method is called when an object is created. The advantage of using this method compared to PHP4 is that the constructor can have a unique name, no matter what the name of the class it is in. In this way, you are changing When changing the name of the class, there is no need to change the name of the constructor
    34. __destruct Destructor method, PHP will call this method before the object is destroyed (that is, before it is cleared from memory). By default, PHP only releases the memory occupied by object properties and destroys object-related resources. The destructor allows you to execute arbitrary code to clear memory after using an object. When PHP decides that your script is no longer associated with the object, the destructor will be called.
    35. In the namespace of a function, this happens when the function returns.
    36. For global variables, this happens at the end of the script.
    37. If you want to explicitly destroy an object, you can assign any other value to the variable pointing to the object. Usually assign the variable to NULL or call unset.
    38. 6.__clone
    39. Object assignment in PHP5 uses reference assignment. If you want to copy an object, you need to use the clone method. When calling this method, the object will automatically call the __clone magic method. If you need to perform some initialization operations when copying the object, This can be achieved in the __clone method.
    40. 7.__toString
    41. The
    42. __toString method is automatically called when converting an object into a string, such as when using echo to print the object.
    43. If the class does not implement this method, the object cannot be printed through echo, otherwise it will display: Catchable fatal error: Object of class test could not be converted to string in
    44. This method must return a string.
    45. Before PHP 5.2.0, the __toString method can only take effect when used in conjunction with echo() or print(). After PHP 5.2.0, it can be used in any string environment (for example, through printf(), using the %s modifier), but it cannot be used in non-string environments (such as using the %d modifier). From PHP 5.2.0, if an object that does not define the __toString method is converted to a string, an E_RECOVERABLE_ERROR error will be reported.
    46. 8, __sleep, __wakeup
    47. __sleep is used when serializing
    48. __wakeup is called during deserialization
    49. serialize() checks whether there is a function with the magic name __sleep in the class. If so, the function will run before any serialization. It clears the object and should return an array containing the names of all variables in the object that should be serialized.
    50. The purpose of using __sleep is to close any database connections the object may have, submit pending data, or perform similar cleanup tasks. Additionally, this function is useful if you have very large objects that do not need to be stored completely.
    51. Conversely, unserialize() checks for the existence of a function with the magic name __wakeup . This function can reconstruct any resources the object may have, if present.
    52. The purpose of using __wakeup is to re-establish any database connections that may have been lost during serialization and to handle other re-initialization tasks.
    53. 9. __set_state
    54. This static method will be called when var_export() is called (valid since PHP 5.1.0).
    55. The only parameter of this method is an array, which contains class properties arranged in the format of array(’property’ => value, …).
    56. 10.__invoke
    57. When trying to call an object by calling a function, the __invoke method will be automatically called.
    58. PHP5.3.0 or above is valid
    59. 11. __callStatic
    60. It works similar to the __call() magic method, __callStatic() is to handle static method calls,
    61. PHP5.3.0 or above is valid
    62. PHP does strengthen the definition of the __callStatic() method; it must be public and must be declared static. Likewise, the __call() magic method must be defined as public, as must all other magic methods
  • Some configure parameters when compiling php
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. ./configure
    2. –prefix=/usr/local/php php installation directory
    3. –with-apxs2=/usr/local/apache/bin/apxs
    4. –with-config-file-path=/usr/local/php/etc Specify the location of php.ini
    5. –with-mysql=/usr/local/mysql mysql installation directory, support for mysql
    6. –with-mysqli=/usr/local/mysql/bin/mysql_config mysqli file directory, optimized support
    7. –enable-safe-mode      turn on safe mode
    8. –enable-ftp Turn on ftp support
    9. –enable-zip Turn on support for zip
    10. –with-bz2 Turn on support for bz2 files
    11. –with-jpeg-dir                                                                                                                                                                                    
    12. –with-png-dir                                                                                                                                                                                                
    13. –with-freetype-dir Turn on support for freetype font library
    14. –without-iconv Turn off the iconv function and convert between character sets
    15. –with-libxml-dir Turn on support for libxml2 library
    16. –with-xmlrpc Open the c language of xml-rpc
    17. –with-zlib-dir                                                                                                                                                                                              
    18. –with-gd Turn on support for gd library
    19. –enable-gd-native-ttf Support TrueType string function library
    20. –with-curl Turn on curl browsing tool support
    21. –with-curlwrappers Use curl tool to open url stream
    22. –with-ttf Open freetype1.* support, you don’t need to add it
    23. –with-xsl Open XSLT file support, extended libxml2 library, requires libxslt software
    24. –with-
    25. gettext Open gnu’s
    26. gettext support, the coding library uses
    27. –with-pear Turn on support for pear command, used for PHP extension
    28. –enable-calendar Turn on the calendar extension
    29. –enable-mbstring Multi-byte, string support
    30. –enable-bcmath Open image size adjustment, this module is used when using zabbix monitoring
    31. –enable-sockets Turn on sockets support
    32. –enable-exif Image metadata support
    33. –enable-magic-quotes Support for magic quotes
    34. –disable-rpath Turn off additional runtime files
    35. –disable-debug Turn off debug mode
    36. –with-mime-magic=/usr/share/file/magic.mime Magic header file location
    37. Parameters only used for cgi installation
    38. –enable-fpm This parameter is only available after applying the php-fpm patch. The startup program installed in cgi mode
    39. –enable-fastcgi Support fastcgi mode to start php
    40. –enable-force-cgi-redirect        Same as above, there is no explanation in the help
    41. –with-ncurses A dynamic library that supports ncurses screen drawing and text terminal-based graphical interaction functions
    42. –enable-pcntl is needed for freeTDS, it may be used to link mssql
    43. Extensions of mhash and mcrypt algorithms
    44. –with-mcrypt Algorithm
    45. –with-mhash Algorithm
    46. –with-gmp
    47. –enable-inline-optimization
    48. –with-openssl Support for openssl, used for encrypted transmission
    49. –enable-dbase
    50. –with-pcre-dir=/usr/local/bin/pcre-config Perl regular library installation location
    51. –disable-dmalloc
    52. –with-gdbm gdbm support for dba
    53. –enable-sigchild
    54. –enable-sysvsem
    55. –enable-sysvshm
    56. –enable-zend-multibyte Support zend multibyte
    57. –enable-mbregex
    58. –enable-wddx
    59. –enable-shmop
    60. –enable-soap
    61. Full list of PHP configuration options
    62. Database options
    63. –with-dbplus
    64. Includes dbplus support.
    65. –with-adabas[=DIR]
    66. Includes Adabas D support. DIR is the basic installation directory of Adabas, which defaults to /usr/local.
    67. –with-sapdb[=DIR]
    68. Includes SAP DB support. DIR is the basic installation directory of SAP DB, which defaults to /usr/local.
    69. –with-solid[=DIR]
    70. Includes Solid support. DIR is the basic installation directory of Solid, which defaults to /usr/local/solid.
    71. –with-ibm-db2[=DIR]
    72. Includes IBM DB2 support.DIR is the basic installation directory of DB2, which defaults to /home/db2inst1/sqllib.
    73. –with-empress[=DIR]
    74. Includes Empress support. DIR is the basic installation directory of Empress, and the default is $EMPRESSPATH. Since PHP4, this option only supports Empress 8.60 and above.
    75. –with-empress-bcs[=DIR]
    76. Includes Empress Local Access support. DIR is the basic installation directory of Empress, and the default is $EMPRESSPATH. Since PHP4, this option only supports Empress 8.60 and above.
    77. –with-birdstep[=DIR]
    78. Includes Birdstep support. DIR is the basic installation directory of Birdstep, which defaults to /usr/local/birdstep.
    79. –with-custom-odbc[=DIR]
    80. Includes user-defined ODBC support. DIR is the basic installation directory of ODBC, which defaults to /usr/local. Make sure CUSTOM_ODBC_LIBS is defined and there is an odbc.h in the include directory. For example, for Sybase SQL Anywhere 5.5.00 under QNX, the following environment variables should be defined before running the configure script: CPPFLAGS=”-DODBC_QNX -DSQLANY_BUG” LDFLAGS=-lunix CUSTOM_ODBC_LIBS=”-ldblib -lodbc”.
    81. –with-iodbc[=DIR]
    82. Includes iODBC support. DIR is the basic installation directory of iODBC, which defaults to /usr/local.
    83. –with-esoob[=DIR]
    84. Includes Easysoft OOB support. DIR is the basic installation directory of OOB, the default is /usr/local/easysoft/oob/client.
    85. –with-unixODBC[=DIR]
    86. Includes unixODBC support. DIR is the basic installation directory of unixODBC, which defaults to /usr/local.
    87. –with-openlink[=DIR]
    88. Includes OpenLink ODBC support. DIR is the basic installation directory of OpenLink, which defaults to /usr/local. This is the same as iODBC.
    89. –with-dbmaker[=DIR]
    90. Includes DBMaker support. DIR is the basic installation directory of DBMaker, which defaults to the directory where the latest version of DBMaker is installed (for example, /home/dbmaker/3.6).
    91. –disable-unified-odbc
    92. Remove support for unified ODBC. Only applicable if iODBC, Adabas, Solid, Velocis or user-defined ODBC interface is activated. Only works with PHP 3!
    93. Image options
    94. –without-gd
    95. Disable GD support. Only for PHP 3!
    96. –with-imagick
    97. The Imagick extension has been moved to PECL in PEAR and can be found here. Installation instructions for PHP 4 can be found on the PEAR site.
    98. Using --with-imagick is only supported in PHP 3 unless you follow the instructions on the PEAR site.
    99. –with-ming[=DIR]
    100. Includes ming support.
    101. Miscellaneous options
    102. –enable-force-cgi-redirect
    103. Activate security checks for internal server redirections. This option should be used if PHP is used in CGI mode with Apache.
    104. –enable-discard-path
    105. Using this option allows PHP's CGI executable program to be safely placed outside the web directory tree, and others cannot bypass the security settings of .htaccess.
    106. –with-fastcgi
    107. Compile PHP into FastCGI application.
    108. –enable-debug
    109. Add debugging symbols when compiling.
    110. –with-layout=TYPE
    111. Set the file layout after installation. TYPE can be PHP (default) or GNU.
    112. –with-pear=DIR
    113. Install PEAR in the DIR directory (default is PREFIX/lib/php).
    114. –without-pear
    115. Do not install PEAR.
    116. –enable-sigchild
    117. Activate PHP's own SIGCHLD handle.
    118. –disable-rpath
    119. Disable passing additional runtime library search paths.
    120. –enable-libgcc
    121. Activate explicit libgcc linkage.
    122. –enable-php-streams
    123. Contains experimental PHP streams. Don't use it unless you are testing the source code!
    124. –with-zlib-dir=;
    125. Define the installation path of zlib.
    126. –with-aspell[=DIR]
    127. Contains ASPELL support.
    128. –with-ccvs[=DIR]
    129. Contains CCVS support.
    130. –with-cybercash[=DIR]
    131. Includes CyberCash support. DIR is the installation directory of CyberCash MCK.
    132. –with-icap[=DIR]
    133. Contains ICAP support.
    134. –with-ircg-config
    135. The path to the ircg-config script.
    136. –with-ircg
    137. Contains ircg support.
    138. –enable-mailparse
    139. Contains mailparse support.
    140. –with-muscat[=DIR]
    141. Contains muscat support.
    142. –with-satellite[=DIR]
    143. Activate CORBA support via Satellite (experimental). DIR is the home directory of ORBit.
    144. –enable-trans-sid
    145. Activate transparent session id propagation.
    146. –with-regex[=TYPE]
    147. Use system regex library (deprecated).
    148. –with-vpopmail[=DIR]
    149. Includes vpopmail support.
    150. –with-tsrm-pthreads
    151. Use POSIX threads (default).
    152. –enable-shared[=PKGS]
    153. Compile shared libraries [default=yes].
    154. –enable-static[=PKGS]
    155. Compile static library [default=yes].
    156. –enable-fast-install[=PKGS]
    157. Optimized for fast installation [default=yes].
    158. –with-gnu-ld
    159. Assume that the C compiler uses GNU ld [default=no].
    160. –disable-libtool-lock
    161. Avoid locking (which may break parallel compilation).
    162. –with-pic
    163. Try to use only PIC/non-PIC objects [default=use both].
    164. –enable-memory-limit
    165. Add memory limit support when compiling.
    166. –disable-url-fopen-wrapper
    167. The fopen wrapper via URL is prohibited, and files cannot be accessed via HTTP or FTP.
    168. –enable-versioning
    169. Only output the required symbols. See the INSTALL file for more information.
    170. –with-imsp[=DIR]
    171. Includes IMSP support (DIR is IMSP's include directory and libimsp.a directory). Only for PHP 3!
    172. –with-mck[=DIR]
    173. Includes Cybercash MCK support. DIR is the cybercash mck compilation directory, the default is /usr/src/mck-3.2.0.3-linux. See extra/cyberlib for help. Only for PHP 3!
    174. –with-mod-dav=DIR
    175. Contains DAV support via Apache's mod_dav. DIR is the installation directory of mod_dav (only for Apache module versions!) Only for PHP 3!
    176. –enable-debugger
    177. Compile into remote debugging functions. Only for PHP 3!
    178. –enable-versioning
    179. Take advantage of version control and scope provided by Solaris 2.x and Linux. Only for PHP 3!
    180. PHP Options
    181. –enable-maintainer-mode
    182. Activation puts compilation rules and unused (and some obfuscated) dependency files into a temporary installation.
    183. –with-config-file-path=PATH
    184. Set the path where php.ini is located. The default is PREFIX/lib.
    185. –enable-safe-mode
    186. Safe mode is activated by default.
    187. –with-exec-dir[=DIR]
    188. In safe mode, only programs in this directory are allowed to execute. The default is /usr/local/php/bin.
    189. –enable-magic-quotes
    190. Magic quotes are activated by default.
    191. –disable-short-tags
    192. The abbreviated PHP start tag is prohibited by default.
    193. Server Options
    194. –with-aolserver=DIR
    195. Specify the path to the installed AOLserver.
    196. –with-apxs[=FILE]
    197. Compile shared Apache module. FILE is the path to the optional Apache apxs tool, which defaults to apxs. Make sure that the specified apxs version is the installed file and not the package in the Apache source program.
    198. –with-apache[=DIR]
    199. Compile Apache module. DIR is the highest-level directory of Apache source programs. The default is /usr/local/apache.
    200. –with-mod_charset
    201. Activate the transfer table in mod_charset (in Apache).
    202. –with-apxs2[=FILE]
    203. Compile shared Apache 2.0 modules. FILE is the path to the optional Apache apxs tool, which defaults to apxs.
    204. –with-fhttpd[=DIR]
    205. Compile the fhttpd module. DIR is the source code path of fhttpd, which defaults to /usr/local/src/fhttpd.
    206. –with-isapi=DIR
    207. Compile PHP to ISAPI module for Zeus.
    208. –with-nsapi=DIR
    209. Specify the path to the installed Netscape server.
    210. –with-phttpd=DIR
    211. No information yet.
    212. –with-pi3web=DIR
    213. Compile PHP into a module for Pi3Web.
    214. –with-roxen=DIR
    215. Compile PHP into a Pike module. DIR is the root directory of Roxen, usually /usr/local/roxen/server.
    216. –enable-roxen-zts
    217. Compile Roxen module and use Zend Thread Safety.
    218. –with-servlet[=DIR]
    219. Contains servlet support. DIR is the basic installation directory of JSDK. This SAPI requires a java extension that must be compiled into a shared dl.
    220. –with-thttpd=SRCDIR
    221. Compile PHP into thttpd module.
    222. –with-tux=MODULEDIR
  • Two ways to pass parameters to php.
  • (mysql) Please write the meaning of data type (int char varchar datetime text); What is the difference between varchar and char;
    Sql code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. char is a fixed-length type, and varchar is a variable-length type. The difference between them is:
    2. In a data column of type char(M), each value occupies M bytes. If a length is less than M, MySQL will pad it with space characters on the right. (The padded space characters will be removed during the retrieval operation) In the varchar(M) type data column, each value only occupies just enough bytes plus one to record its length. Bytes (that is, the total length is L+1 bytes).
    3. Rules used in MySQL to determine whether column type conversion is required
    4. 1. In a data table, if the length of each data column is fixed, then the length of each data row will also be fixed.
    5. 2. As long as there is a variable length of data column in the data table, then the length of each data row is variable.
    6. 3. If the length of the data rows in a data table is variable, then, in order to save storage space, MySQL will convert the fixed-length data columns in the data table into the corresponding variable-length type. .
    7. Exception: char data columns less than 4 characters in length will not be converted to varchar type
    8. A fixed length
    9. An indefinite length
    10. a char(10)
    11. b varchar(10)
    12. Deposit all into 'abc'
    13. a 10 bytes
    14. b 3 bytes
  • Error_reporting and other debugging functions are used
  • Have you ever used version control software? If so, what is the name of the version control software you used?
  • The difference between posix and perl standard regular expressions;
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. Regular Expression (abbreviated as regexp, regex or regxp), also known as regular expression, regular expression or regular expression or normalized expression or regular expression, refers to a method used to describe or match A sequence of individual strings that conform to a certain syntax rule. In many text editors or other tools, regular expressions are often used to retrieve and/or replace text content that matches a certain pattern. Many programming languages ​​support string manipulation using regular expressions. For example, Perl has a powerful regular expression engine built into it. The concept of regular expressions was originally popularized by tool software in Unix (such as sed and grep). (Excerpted from Wikipedia)
    2. PHP uses two sets of regular expression rules at the same time. One is the POSIX Extended 1003.2 compatible regular expression formulated by the Institute of Electrical and Electronics Engineers (IEEE) (in fact, PHP's support for this standard is not perfect), and the other is from The PCRE (Perl Compatible Regular Expression) library provides PERL-compatible regular expressions. This is an open source software authored by Philip Hazel.
    3. The functions that use POSIX compatibility rules are:
    4. ereg_replace()
    5. ereg()
    6. eregi()
    7. eregi_replace()
    8. split()
    9. spliti()
    10. sql_regcase()
    11. mb_ereg_match()
    12. mb_ereg_replace()
    13. mb_ereg_search_getpos()
    14. mb_ereg_search_getregs()
    15. mb_ereg_search_init()
    16. mb_ereg_search_pos()
    17. mb_ereg_search_regs()
    18. mb_ereg_search_setpos()
    19. mb_ereg_search()
    20. mb_ereg()
    21. mb_eregi_replace()
    22. mb_eregi()
    23. mb_regex_encoding()
    24. mb_regex_set_options()
    25. mb_split()
    26. Functions that use PERL compatibility rules are:
    27. preg_grep()
    28. preg_replace_callback()
    29. preg_match_all()
    30. preg_match()
    31. preg_quote()
    32. preg_split()
    33. preg_replace()
    34. Delimiter:
    35. POSIX-compatible regular expressions have no delimiters, and the corresponding parameters of the function will be considered regular expressions.
    36. PERL-compatible regular expressions can use any character that is not a letter, number, or backslash () as a delimiter. If the character as a delimiter must be used in the expression itself, it needs to be escaped with a backslash. . You can also use (), {}, [] and as delimiters
    37. Modifier:
    38. POSIX compatible regular expressions have no modifiers.
    39. Possible modifiers used in PERL compatible regular expressions (spaces and newlines in the modifiers are ignored, other characters will cause errors):
    40. i (PCRE_CASELESS):
    41. Ignore case when matching.
    42. m (PCRE_MULTILINE):
    43. When this modifier is set, the start of line (^) and the end of line ($) not only match the beginning and end of the entire string, but also match after and before the newline character (n).
    44. s (PCRE_DOTALL):
    45. If this modifier is set, the dot metacharacter (.) in the pattern matches all characters, including newlines. Without this setting, newline characters are not included.
    46. x(PCRE_EXTENDED):
    47. If this modifier is set, whitespace characters in the pattern are completely ignored except those that are escaped or within a character class.
    48. e:
    49. If this modifier is set, preg_replace() performs the normal replacement of the backreference in the replacement string, evaluates it as PHP code, and uses its result to replace the searched string. Only preg_replace() uses this modifier, other PCRE functions ignore it.
    50. A (PCRE_ANCHORED):
    51. If this modifier is set, the pattern is forced to be "anchored", that is, it is forced to match only from the beginning of the target string.
    52. D (PCRE_DOLLAR_ENDONLY):
    53. If this modifier is set, end-of-line ($) in the pattern only matches the end of the target string. Without this option, if the last character is a newline character, it will also be matched. This option is ignored if the m modifier is set.
    54. S:
    55. When a pattern is going to be used several times, it is worth analyzing it first to speed up matching. If this modifier is set additional analysis will be performed. Currently, analyzing a pattern is only useful for non-anchored patterns that do not have a single fixed starting character.
    56. U(PCRE_UNGREEDY):
    57. Make the default matching of "?" greedy.
    58. X (PCRE_EXTRA):
    59. Any backslash in the
    60. pattern followed by a letter with no special meaning results in an error, thus preserving this combination for future expansion. By default, a backslash followed by a letter with no special meaning is treated as the letter itself.
    61. u(PCRE_UTF8):
    62. Pattern strings are treated as UTF-8.
    63. Logical segmentation:
    64. The logical separator symbols of POSIX compatible regular expressions and PERL compatible regular expressions have exactly the same function and usage:
    65. []: Contains information related to any selected operation.
    66. {}: Contains information about the number of matches.
    67. (): Contains relevant information of a logical interval and can be used for reference operations.
    68. |: means "or", [ab] and a|b are equivalent.
    69. The
    70. metacharacter is related to "[]":
    71. There are two different sets of metacharacters: one is recognized within the pattern except square brackets, and the other is recognized within square brackets "[]".
    72. POSIX compatible regular and PERL compatible regular "[]" and "consistent" metacharacters:
    73. Universal escape character with several uses
    74. ^ matches the beginning of the string
    75. $ matches the end of the string
    76. ? Matches 0 or 1
    77. * matches 0 or more characters of the previously specified type
    78. + matches 1 or more characters of the previously specified type
    79. POSIX compatible regular and PERL compatible regular "[]" and "inconsistent" metacharacters:
    80. . PERL compatible regular match any character except newline character
    81. . POSIX compatible regular match any character
    82. POSIX compatible regular and PERL compatible regular "within []" "consistent" metacharacters:
    83. Universal escape character with several uses
    84. ^ negates the character, but is only valid when it is the first character
    85. - Specify the character ASCII range, study the ASCII code carefully, you will find that [W-c] is equivalent to [WXYZ\^_`abc]
    86. POSIX compatible regular and PERL compatible regular "inconsistent" metacharacters "within []":
    87. - The specification of [a-c-e] in POSIX compatible regular expressions will throw an error.
    88. - The specification of [a-c-e] in PERL compatible regular expressions is equivalent to [a-e].
    89. The number of matches is related to "{}":
    90. POSIX compatible regular expressions and PERL compatible regular expressions are exactly the same in terms of matching times:
    91. {2}: Indicates matching the previous character 2 times
    92. {2,}: Indicates matching the previous character 2 or more times. The default is greedy (as many as possible) matching
    93. {2,4}: Indicates matching the previous character 2 or 4 times
    94. Logical intervals are related to "()":
    95. The area enclosed by () is a logical interval. The main function of the logical interval is to reflect the logical order in which some characters appear. Another use is that it can be used for reference (the value in this interval can be referenced to a variable ).The latter effect is rather strange:
    96. $str = "http://www.163.com/";
    97. // POSIX compatible regular:
    98. echo ereg_replace("(.+)","\1",$str);
    99. // PERL compatible regular expression:
    100. echo preg_replace("/(.+)/","$1",$str);
    101. // Display two links
    102. ?>
    103. When quoting, brackets can be nested, and the logical order is calibrated according to the order in which "(" appears.
    104. Type matching:
    105. POSIX compatible regex:
    106. [:upper:]: Match all uppercase letters
    107. [:lower:]: Match all lowercase letters
    108. [:alpha:]: Match all letters
    109. [:alnum:]: Match all letters and numbers
    110. [:digit:]: Match all digits
    111. [:xdigit:]: matches all hexadecimal characters, equivalent to [0-9A-Fa-f]
    112. [:punct:]: matches all punctuation marks, equivalent to [.,"'?!;:]
    113. [:blank:]: matches spaces and TAB, equivalent to [t]
    114. [:space:]: matches all whitespace characters, equivalent to [tnrfv]
    115. [:cntrl:]: Matches all control characters between ASCII 0 and 31.
    116. [:graph:]: matches all printable characters, equivalent to: [^ tnrfv]
    117. [:print:]: matches all printable characters and spaces, equivalent to: [^tnrfv]
    118. [.c.]: Unknown function
    119. [=c=]:Unknown function
    120. [:<: matches the beginning of a word>
    121. [:>:]: Match the end of the word
    122. PERL compatible regular expressions (here you can see the power of PERL regular expressions):
    123. a alarm, which is the BEL character (’0)
    124. cx "control-x", where x is any character
    125. e escape(’0B)
    126. f formfeed (’0C)
    127. n newline character newline (’0A)
    128. r Carriage return(’0D)
    129. t tab (’0)
    130. xhh The character whose hexadecimal code is hh
    131. ddd The character whose octal code is ddd , or backreference
    132. d Any decimal number
    133. D Any non-decimal character
    134. s any whitespace character
    135. S Any non-whitespace character
    136. w Any character of "word"
    137. W Any "non-word" character
    138. b word dividing line
    139. B non-character dividing line
    140. Beginning of A target (independent of multiline mode)
    141. Z End of target or before trailing newline (independent of multiline mode)
    142. z end of target (independent of multiline mode)
    143. G first matching position in target
  • What areas are restricted after Safe_mode is turned on?
  • Write code to solve the problem of multiple processes/threads reading and writing a file at the same time.
    Php code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. As we all know, PHP does not have the concept of multi-threading. However, we can still use "imperfect" methods to simulate multi-threading. Simply put, it is queue processing. This is achieved by locking and unlocking files. When a file is operated by one user, the file is locked, and other users can only wait. It is indeed not perfect, but it can also meet some applications with low requirements.
    2. function T_put($filename,$string){
    3. $fp = fopen($filename,'a'); //Open in append mode
    4. if (flock($fp, LOCK_EX)){ //Add write lock
    5. fputs($fp,$string); //Write file
    6. flock($fp, LOCK_UN); //Unlock
    7. }
    8. fclose($fp);
    9. }
    10. function T_get($filename,$length){
    11. $fp = fopen($filename,'r'); //Open in append mode
    12. if (flock($fp, LOCK_SH)){ //Add read lock
    13. $result = fgets($fp,$length); //Read file
    14. flock($fp, LOCK_UN); //Unlock
    15. }
    16. fclose($fp);
    17. return $result;
    18. }
  • Write a piece of code to upload files.
  • Mysql storage engine, the difference between myisam and innodb.
    Sql code I compiled a list of interview questions for recruiting PHP senior engineers, PHP senior engineer_PHP tutorial
    1. Simple expression.
    2. MyISAM is a non-transactional storage engine.
    3. Innodb is a storage engine that supports transactions.
    4. The innodb engine is more suitable for applications with a lot of insert and update operations
    5. MyISAM is suitable for applications with frequent queries
    6. MyISAM --Table lock.
    7. innodb--If designed properly, it is a row lock.
    8. MyISAM will not cause deadlock.
    9. The biggest difference is that MYISAM is suitable for small data and small concurrency; INNODB is suitable for big data and large concurrency. The biggest difference is at the lock level.
    10. The MyISAM type does not support advanced processing such as transaction processing, while the InnoDB type does. The MyISAM type table emphasizes performance, and its execution times are faster than the InnoDB type, but it does not provide transaction support, while InnoDB provides transaction support and advanced database functions such as foreign keys. To summarize, different storage types can be used according to the different uses of the data table. Moreover, MyISAM is file storage and can be copied directly between different operating systems.
    11. InnoDB:
    12. InnoDB provides MySQL with transaction-safe (transaction-safe (ACID compliant)) type with transaction (commit), rollback (rollback) and crash recovery capabilities (crash recovery capabilities) surface. InnoDB provides row locking (locking on row level) and non-locking read (non-locking read in SELECTs) consistent with Oracle type. These features improve the performance of multi-user concurrent operations. There is no need to expand locks (lock escalation) in InnoDB tables because InnoDB's column locks (row level locks) fit in very small spaces. InnoDB is the first table engine on MySQL to provide foreign key constraints (FOREIGN KEY constraints). InnoDB is designed to handle large-capacity database systems, and its CPU utilization is unmatched by other disk-based relational database engines. Technically, InnoDB is a complete database system placed in the background of MySQL. InnoDB establishes its own dedicated buffer pool in main memory for caching data and indexes. InnoDB stores data and indexes in a table space, which may contain multiple files, which is different from others. For example, in MyISAM, tables are stored in separate files. The size of an InnoDB table is limited only by the file size of the operating system, which is typically 2 GB. All tables in InnoDB are stored in the same data file ibdata1 (it may be multiple files, or independent table space files). It is relatively difficult to back up. You can copy the file or use navicat for mysql.
    13. MyISAM
    14. Each MyISAM table is stored in three files: the frm file stores the table definition. The data file is MYD (MYData). The index file is an extension of MYI (MYIndex).
    15. Because MyISAM is relatively simple, it is better than InnoDB in terms of efficiency. It is a good choice for small applications to use MyISAM.
    16. MyISAM tables are saved as files. Using MyISAM storage in cross-platform data transfer will save a lot of trouble
  • 2. Web architecture, security, project experience

    3. Basic use of unix/linux

    4. Front-end, HTML, JS

    php interview questions


    Which of the following sentences will not add John to the users array?
    $users[] = 'john';
    Successfully added John to the users array.
    array_add($users,’john’);
    Function array_add() has no definition.
    array_push($users,‘john’);
    Successfully added John to the array users.
    $users ||= 'john';
    Syntax error.
    2. What are the differences between sort(), assort(), and ksort()? Under what circumstances are they used?
    sort()
    Sort in English alphabetical order according to the value of the elements in the array, and the index keys will be renumbered from 0 to n-1. Mainly used to sort the array when the value of the array index key is irrelevant.
    assort()
    PHP does not have assort() function, so it may be a typo in asort().
    asort()
    Like sort(), it arranges the elements of the array in English alphabetical order. The difference is that all index keys are retained, which is especially suitable for sorting associative arrays.
    ksort()
    Sort in English alphabetical order according to the value of the index key in the array. It is especially suitable for associative arrays that want to sort the index keys.
    3. What will the following code produce? Why?
    $num =10;
    function multiply(){
    $num =$num *10;
    }
    multiply();
    echo $num;
    Due to function The formula multiply() does not specify $num as a global variable (such as global $num or $_GLOBALS['num']), so the value of $num is 10.
    4. What is the difference between a reference and a regular variable? How to pass by reference? Under what circumstances do we need to do this?
    Reference transfers the address of the variable rather than its value, so when the value of a variable is changed in a function, the entire application will see the variable.

    Related labels:
    source:php.cn
    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
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!