Home > Article > Backend Development > The latest summary of PHP interview questions and answers
This article will share with you the latest summary of PHP interview questions and answers. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Related recommendations: "The latest summary of application questions for PHP interview questions""The latest summary of PHP interview questions for conceptual questions"
echo() and print() are PHP statements; print_r() is a function,
error_reporting() sets the error level of PHP and returns the current level.
session is stored on the server side, and cookie is stored on the client side.
Session is relatively safe, but cookies can be modified by certain means, which is not safe.
The running of session depends on the session id, and the session id is stored in the cookie. If cookies are disabled, the session will become invalid. (But it can be achieved in other ways, such as passing the session id in the url).
session can be placed in a file, database or memory. By default it is stored in a file on the server.
get is explicit, the data can be seen from the url, and the amount of data transferred is small , low security;
post is implicit, the amount of data transmitted is large, and security is high.
d086f5c0caeae0359a214da9ffbdab77PHP0d36329ec37a2cc24d42c7229b69747a 0c6dc11e160d3b678d68754cc175188a Title: a4b561c25d9afb9ac8dc4d70affff419Programming Language0d36329ec37a2cc24d42c7229b69747a"; preg_match_all ("/a4b561c25d9afb9ac8dc4d70affff419(.*)ff5ce9b4edd32c649942decae47f914a/U", $userinfo, $pat_array); strpos("I love php, I love php too!","php"); // 首次匹配的位置 strrpos("I love php, I love php too!","php"); // 最后匹配的位置
Fast speed: Because the data is stored in memory, similar to HashMap, the advantage of HashMap is that the time complexity of search and operation is O(1).
Support rich data types: support string, list, set, sorted set, hash.
Support transactions: multiple commands can be executed at one time. Failure will not roll back and execution will continue.
Rich features: can be used for caching, messaging, setting expiration time by key, it will be automatically deleted after expiration
All values in memcached are simple strings, and redis, as its replacement, supports richer data types.
redis is much faster than memcached.
redis can persist its data
First enter the PHP installation directory. The -f parameter specifies the PHP file to be executed. The parameters are directly connected after the file name. Multiple parameters are separated by spaces. -r means to execute php code directly.
If arguments are passed, the script will first check $argc to ensure that the number of arguments meets the requirements. Then each argument is extracted from $argv and printed to standard output.
$ php -f d:/wamp/test.php [参数1 参数2 ...] $ php -r phpinfo();
Program executed in minutes, hours, days, months and weeks
案例: 一个备份程序mybackup
,需要在周一到周五下午1点和晚上8点运行,命令如下:
0 13,20 * * 1,2,3,4,5 mybackup // 或 0 13,20 * * 1-5 mybackup
浏览器从地址栏的输入中获得服务器的 IP 地址和端口号;
浏览器用 TCP 的三次握手与服务器建立连接;
浏览器向服务器发送拼好的报文;
服务器收到报文后处理请求,同样拼好报文再发给浏览器;
浏览器解析报文,渲染输出页面。
array_combine()-----通过合并两个数组来创建一个新数组 array_chunk()-------将一个数组分割成多个 array_merge()-------把两个或多个数组合并成一个数组 array_slice()-------在数组中根据条件取出一段值 array_diff()--------返回两个数组的差集数组 array_intersect()---计算数组的交集 array_search()------在数组中搜索给定的值 array_splice()------移除数组的一部分且替代它 array_key_exists()--判断某个数组中是否存在指定的key array_flip()--------交换数组中的键和值 array_reverse()-----将原数组中的元素顺序翻转,创建新的数组并返回 array_unique()------移除数组中重复的值 range()-------------创建并返回一个包含指定范围的元素的数组
sort() - 以升序对数组排序 rsort() - 以降序对数组排序 asort() - 根据值,以升序对关联数组进行排序 ksort() - 根据键,以升序对关联数组进行排序 arsort() - 根据值,以降序对关联数组进行排序 krsort() - 根据键,以降序对关联数组进行排序
// http://www.test.com/testA/test?name=aj&age=23 "HTTP_HOST" => "www.test.com" "SERVER_NAME" => "www.test.com" "SERVER_PORT" => "80" // 服务器端口 "SERVER_ADDR" => "127.0.0.1" // 服务器IP "REMOTE_PORT" => "13675" // 客户端IP "REMOTE_ADDR" => "127.0.0.1" // 客户端口 "REQUEST_URI" => "/testA/test?name=aj&age=23" // 参数 "SCRIPT_NAME" => "/index.php" "QUERY_STRING" => "s=//testA/test&name=aj&age=23" "SCRIPT_FILENAME" => "F:/projectName/public/index.php" // 当前执行脚本路径
__construct(),类的构造函数 __destruct(),类的析构函数 __call(),在对象中调用一个不可访问方法时调用 __callStatic(),用静态方式中调用一个不可访问方法时调用 __get(),获得一个不存在的类成员变量时调用 __set(),设置一个不存在的类成员变量时调用 __isset(),当对不可访问属性调用isset()或empty()时调用 __unset(),当对不可访问属性调用unset()时被调用。 __sleep(),执行serialize()时,先会调用这个函数 __wakeup(),执行unserialize()时,先会调用这个函数 __toString(),类被当成字符串时的回应方法 __invoke(),调用函数的方式调用一个对象时的回应方法 __set_state(),调用var_export()导出类时,此静态方法会被调用。 __clone(),当对象复制完成时调用 __autoload(),尝试加载未定义的类 __debugInfo(),打印所需调试信息
本文章首发在 LearnKu.com 网站上。
The above is the detailed content of The latest summary of PHP interview questions and answers. For more information, please follow other related articles on the PHP Chinese website!