Heim > php教程 > php手册 > Hauptteil

高级php面试题及部分答案

WBOY
Freigeben: 2016-06-06 19:55:33
Original
1121 Leute haben es durchsucht

在网上看到一些高级php 的面试题目…… 闲来无事,搞了一些答案……可能不是很全面,留这以后备用吧。 一。 基本知识点 1.1 HTTP协议中几个状态码的含义:503 500 401 403 404 200 301 302…… 200 : 请求成功,请求的数据随之返回。 301 : 永久性重定向。 3

    在网上看到一些高级php 的面试题目……

    闲来无事,搞了一些答案……可能不是很全面,留这以后备用吧。

    一。 基本知识点

    1.1 HTTP协议中几个状态码的含义:503 500 401 403 404 200 301 302……

    200 : 请求成功,请求的数据随之返回。

    301 : 永久性重定向。

    302 : 暂时行重定向。

    401 : 当前请求需要用户验证。

    403 : 服务器拒绝执行请求,即没有权限。

    404 : 请求失败,请求的数据在服务器上未发现。

    500 : 服务器错误。一般服务器端程序执行错误。

    503 : 服务器临时维护或过载。这个状态时临时性的。

    1.2 Include require include_once require_once 的区别。

    处理失败方式不同:

    require 失败时会产生一个致命级别错误,并停止程序运行。

    include 失败时只产生一个警告级别错误,程序继续运行。

    include_once/require_once和include/require 处理错误方式一样,

    唯一区别在于当所包含的文件代码已经存在时候,不在包含。

    1.3 PHP/Mysql中几个版本的进化史,比如mysql4.0到4.1,PHP 4.x到5.1的重大改进等等。

    1.4 HEREDOC介绍

    一种定义字符串的方法。

    结构:

   

    然后是一个新行。接下来是字符串 本身,

    最后要用前面定义的标识符作为结束标志(单独一行)

    注意:

    只能包含字母、数字和下划线,并且必须以字母和下划线作为开头

    1.5 写出一些php魔幻(术)方法;

    __construct() 实例化类时自动调用。

    __destruct() 类对象使用结束时自动调用。

    __set() 在给未定义的属性赋值的时候调用。

    __get() 调用未定义的属性时候调用。

    __isset() 使用isset()或empty()函数时候会调用。

    __unset() 使用unset()时候会调用。

    __sleep() 使用serialize序列化时候调用。

    __wakeup() 使用unserialize反序列化的时候调用。

    __call() 调用一个不存在的方法的时候调用。

    __callStatic()调用一个不存在的静态方法是调用。

    __toString() 把对象转换成字符串的时候会调用。比如 echo。

    __invoke() 当尝试把对象当方法调用时调用。

    __set_state() 当使用var_export()函数时候调用。接受一个数组参数。

    __clone() 当使用clone复制一个对象时候调用。

    1.6 一些编译php时的configure 参数

    ?prefix=/usr/local/php    php安装目录

    ?with-config-file-path=/usr/local/php/etc 指定php.ini位置

    ?with-mysql=/usr/local/mysql mysql安装目录,对mysql的支持

    ?with-mysqli=/usr/local/mysql/bin/mysql_config mysqli文件目录,优化支持

    ?enable-safe-mode 打开安全模式

    ?enable-ftp 打开ftp的支持

    ?enable-zip 打开对zip的支持

    ?with-bz2 打开对bz2文件的支持

    ?with-jpeg-dir 打开对jpeg图片的支持

    ?with-png-dir 打开对png图片的支持

    ?with-freetype-dir 打开对freetype字体库的支持

    ?without-iconv关闭iconv函数,种字符集间的转换

    ?with-libxml-dir 打开libxml2库的支持

    ?with-xmlrpc 打开xml-rpc的c语言

    ?with-zlib-dir 打开zlib库的支持

    ?with-gd 打开gd库的支持

    更多可以使用 ./configure help 查看

    1.7 向php传入参数的三种方法。

    /*

    * 方法一 使用$argc $argv

    *  在命令行下运行 /usr/local/php/bin/php ./getopt.php -f 123 -g 456

    */

    //    if ($argc > 1){

    //        print_r($argv);

    //    }

    /**

    * 运行结果

    *

    sync@MySUSE11:~/web_app/channel3/interface> /usr/local/php/bin/php ./getopt.php -f 123 -g 456

    Array

    (

    [0] => ./getopt.php

    [1] => -f

    [2] => 123

    [3] => -g

    [4] => 456

    )

    */

    /*

    * 方法二 使用getopt函数()

    *  在命令行下运行 /usr/local/php/bin/php ./getopt.php -f 123 -g 456

    */

    //    $options = "f:g:";

    //    $opts = getopt( $options );

    //    print_r($opts);

    /**

    * 运行结果

    *

    sync@MySUSE11:~/web_app/channel3/interface> /usr/local/php/bin/php ./getopt.php -f 123 -g 456

    Array

    (

    [f] => 123

    [g] => 456

    )

    */

    /*

 

[1] [2] 

高级php面试题及部分答案

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!