2018php latest interview questions PHP core technology

不言
Release: 2023-04-03 12:00:02
Original
18406 people have browsed it

This article shares with you the latest PHP core technology about the 2018php interview questions. Friends in need can refer to it.

Related recommendations: "2019 PHP interview questions summary (collection)"

1. PHP core technology

1. Write a PHP function that can create multi-level directories (Sina Technology Department)

<?php
    /**
     * 创建多级目录
     * @param $path string 要创建的目录
     * @param $mode int 创建目录的模式,在windows下可忽略
     */
    function create_dir($path,$mode = 0777)
    {
        if (is_dir($path)) {
            # 如果目录已经存在,则不创建
            echo "该目录已经存在";
        } else {
            # 不存在,创建
            if (mkdir($path,$mode,true)) {
                echo "创建目录成功";
            } else {
                echo "创建目录失败";
            }
        }
    }
?>
Copy after login

2. Write the characteristics of the smarty template (Sina Technology Department)

Fast speed, compilation, caching technology, plug-in mechanism, powerful performance logic

3. What functions will be affected by opening safe_mode in php.ini? Name at least 6. (Sina)

safe_mode, PHP safe mode, which provides a basic secure shared environment on a PHP developed web server with multiple user accounts. When safe mode is turned on, some functions will be completely prohibited, while the functions of other functions will be restricted, such as: chdir, move_uploaded_file, chgrp, parse_ini_file, chown, rmdir, copy, rename, fopen, require, mkdir, unlink etc.
Note that in php5.3 and above, safe_mode is deprecated, and in php5.4 and above, this feature is completely removed.

4. What function would you use to capture remote images locally? (51.com written test question)

file_get_contents or curl

5.What is the garbage collection mechanism of PHP (Tencent)

PHP can automatically manage memory and clear objects that are no longer needed.
PHP uses reference counting (reference counting) this simple garbage collection (garbage collection) mechanism. Each object contains a reference counter, and each reference connected to the object increases the counter by one. When reference leaves the living space or is set to NULL, the counter is decremented by 1. When an object's reference counter reaches zero, PHP knows that you no longer need to use the object and releases the memory space it occupies.

6. Please write a piece of PHP code to ensure that multiple processes can write the same file successfully at the same time (Tencent)

Core idea: lock

<?php
    $fp = fopen("lock.txt","w+");
    if (flock($fp,LOCK_EX)) {
        //获得写锁,写数据
        fwrite($fp, "write something");
 
        // 解除锁定
        flock($fp, LOCK_UN);
    } else {
        echo "file is locking...";
    }
    fclose($fp);
?>
Copy after login

7. Write a function to retrieve the file extension from a standard URL as efficiently as possible, for example: http://www.sina.com.cn/abc/de/fg.php?id =1 Need to take out php or .php (Sina)

<?php
    // 方案一
    function getExt1($url){
        $arr = parse_url($url);
        //Array ( [scheme] => http [host] => www.sina.com.cn [path] => /abc/de/fg.php [query] => id=1 )
 
        $file = basename($arr[&#39;path&#39;]);
        $ext = explode(&#39;.&#39;, $file);
        return $ext[count($ext)-1];
    }
 
    // 方案二
    function getExt2($url){
        $url = basename($url);
        $pos1 = strpos($url,&#39;.&#39;);
        $pos2 = strpos($url,&#39;?&#39;);
 
        if (strstr($url,&#39;?&#39;)) {
            return substr($url,$pos1+1,$pos2-$pos1-1);
        } else {
            return substr($url,$pos1);
        }
 
    }
 
    $path = "http://www.sina.com.cn/abc/de/fg.php?id=1";
    echo getExt1($path);
    echo "<br />";
    echo getExt2($path);
?>
Copy after login

Related questions: Use more than five ways to get the extension of a file, requirements: dir/upload.image.jpg, find .jpg Or jpg, it must be processed using the processing function that comes with PHP. The method cannot be obviously repeated and can be encapsulated into a function, such as get_ext1(file_name)

8. Write a function that can traverse a folder all files and subfolders. (Sina)

<?php
    function my_scandir($dir){
        $files = array();
        if(is_dir($dir)){
            if ($handle = opendir($dir)) {
                while (($flie = readdir($handle))!== false) {
                    if ($flie!="." && $file!="..") {
                        if (is_dir($dir."/".$file)) {
                            $files[$file] = my_scandir($dir."/".$file);
                        } else {
                            $files[] = $dir."/".$file;
                        }
                    }
                }
                closedir($handle);
                return $files;
            }
        }
    }
?>
Copy after login

[!!!] 9. Briefly describe the implementation principle of infinite classification in the forum. (Sina)

Create a category table as follows:

CREATE TABLE category(
cat_id smallint unsigned not null auto_increment primary key comment&#39;类别ID&#39;,
cat_name VARCHAR(30)NOT NULL DEFAULT&#39;&#39;COMMENT&#39;类别名称&#39;,
parent_id SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT&#39;类别父ID&#39;
)engine=MyISAM charset=utf8;
Copy after login

Write a function to traverse recursively to achieve infinite classification

<?php
    function tree($arr,$pid=0,$level=0){
        static $list = array();
        foreach ($arr as $v) {
            //如果是顶级分类,则将其存到$list中,并以此节点为根节点,遍历其子节点
            if ($v[&#39;parent_id&#39;] == $pid) {
                $v[&#39;level&#39;] = $level;
                $list[] = $v;
                tree($arr,$v[&#39;cat_id&#39;],$level+1);
            }
        }
        return $list;
    }
?>
Copy after login

10. Write a function, Calculate the relative path of the two files, such as b='/a/b/12/34/c.php'; calculate the relative path of a should be ../../c/d (Sina)

<?php
    function releative_path($path1,$path2){
        $arr1 = explode("/",dirname($path1));
        $arr2 = explode("/",dirname($path2));
 
        for ($i=0,$len = count($arr2); $i < $len; $i++) {
            if ($arr1[$i]!=$arr2[$i]) {
                break;
            }
        }
 
        // 不在同一个根目录下
        if ($i==1) {
            $return_path = array();
        }
 
        // 在同一个根目录下
        if ($i != 1 && $i < $len) {
            $return_path = array_fill(0, $len - $i,"..");
        }
 
        // 在同一个目录下
        if ($i == $len) {
            $return_path = array(&#39;./&#39;);
        }
 
        $return_path = array_merge($return_path,array_slice($arr1,$i));
        return implode(&#39;/&#39;,$return_path);
    }
 
    $a = &#39;/a/b/c/d/e.php&#39;;
    $b = &#39;/a/b/12/34/c.php&#39;;
    $c = &#39;/e/b/c/d/f.php&#39;;
    $d = &#39;/a/b/c/d/g.php&#39;;
 
    echo releative_path($a,$b);//结果是../../c/d
    echo "<br />";
    echo releative_path($a,$c);//结果是a/b/c/d
    echo "<br />";
    echo releative_path($a,$d);//结果是./
    echo "<br />";
?>
Copy after login

11.What is the difference between mysql_fetch_row() and mysql_fetch_array()?

mysql_fetch_row() stores a column of the database in a zero-based array, with the first column at index 0 of the array, the second column at index 1, and so on.
mysql_fetch_assoc() stores a column of the database in an associative array. The index of the array is the field name. For example, my database query returns the three fields "first_name", "last_name", and "email". The index of the array is are "first_name", "last_name" and "email".
mysql_fetch_array() can return the values ​​​​of mysql_fetch_row() and mysql_fetch_assoc() at the same time.

12. 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 higher):

$readcontents=fopen("http://www.phpres.com/index.html","rb");
$contents=stream_get_contents($readcontents);
fclose($readcontents);
echo $contents;
Copy after login

Method 2:

echo file_get_contents("http://www.phpres.com/index.html");
Copy after login

13. Talk about your understanding of mvc

An application is completed by model, view, and controller.
The model layer is responsible for providing data, and operations related to the database are handed over to the model layer for processing. The view layer provides an interactive interface and outputs data, while the controller layer is responsible for receiving requests and distributing them to the corresponding model for processing. , and then call the view layer to display.

14.What does the GD library do? (Yahoo)

The GD library provides a series of APIs for processing images. You can use the GD library to process images. Or generate pictures. On websites, the GD library is usually used to generate thumbnails or to add watermarks to images or to generate reports on website data. GD has been built into the PHP system since version 4.3.0.

15.What function can you use to open a file for reading and writing? (Yahoo)

A.fget();
B.file_open( );
C.fopen();
D.open_file();
Answer: C
fget() This is not a PHP function and will cause an execution error.
file_open() This is not a PHP function and will cause execution errors.
fopen() This is the correct answer. fopen() can be used to open files for reading and writing.
open_file() This is not a PHP function and will cause execution errors.

16.The principle of Smarty

smarty是一个模板引擎,使用smarty主要是为了实现逻辑和外在内容的分离,如果不使用模板的话,通常的做法就是php代码和html代码混编。使用了模板之后,则可以将业务逻辑都放到php文件中,而负责显示内容的模板则放到html文件中。
Smarty在执行display方法的时候,读取模板文件,并进行数据替换,生成编译文件,之后每次访问都会直接访问编译文件,读取编译文件省去了读取模板文件,和字符串替换的时间,所以可以更快,编译文件里时间戳记录模板文件修改时间,如果模板被修改过就可以检测到,然后重新编译(编译是把静态内容保存起来,动态内容根据传入的参数不同而不同)。
如果启用了缓存,则会根据编译文件生成缓存文件,在访问的时候如果有缓存文件并且缓存文件没有过期,则直接访问缓存文件。

相关题目1:能够使HTML和PHP分离开使用的模板

smarty,phplib等

相关题目2:您是否用过模板引擎?如果有您用的模板引擎的名字是?

Smarty

17.PHP如何实现页面跳转

方法一:php函数跳转,缺点,header头之前不能有输出,跳转后的程序继续执行,可用exit中断执行后面的程序。
header("Location:网址");//直接跳转
header("refresh:3;url=http://axgle.za.NET");//三秒后跳转

方法二:利用meta
echo"";

18.PHP可以和sql server/oracle等数据库连接吗?

可以

19.使用哪些工具进行版本控制?

SVN或者CVS

相关题目:您是否用过版本控制软件?如果有您用的版本控制软件的名字是?

TortoiseSVN-1.2.6

20.写出一个正则表达式,过虑网页上的所有JS/VBS脚本(即把script标记及其内容都去掉):

过滤JavaScript脚本参考:

<?php
    header("content-type:text/html;charset=utf-8");
 
    $script = "以下内容不显示:<script type=&#39;text/javascript&#39;>alert(&#39;cc&#39;);</script>";
    $pattern = &#39;/<script[^>]*?>.*?</script>/si&#39;;
 
    echo preg_replace($pattern, "脚本内容", $script);//以下内容不显示:脚本内容
?>
Copy after login

21.Given a line of text $string,how would you write a regular expression to strip all the HTML tags from it?(Yahoo)

方案一,使用PHP内建函数strip_tags()除去HTML标签
方案二,自定义函数,如下:

<?php
    header("content-type:text/html;charset=utf-8");
 
    function strip_html_tags($str){
        $pattern = &#39;/<("[^"]*"|\&#39;[^\&#39;]\*\&#39;|[^>"\&#39;])*>/&#39;;
        return preg_replace($pattern,&#39;&#39;,$str);
    }
 
    // 实例
    $html = &#39;<p id="">ddddd<br /></p>&#39;;
    echo strip_html_tags($html);
    echo "<br />";
 
    $html = &#39;<p id=">">bb<br />aaa<br /></p>&#39;;
    echo strip_html_tags($html);
?>
Copy after login

22.请写一个函数验证电子邮件的格式是否正确(要求使用正则)(新浪)

preg_match('/^[\w\-\.]+@[\w\-]+(\.\w+)+$/',$email);

相关题目:请用正则表达式写一个函数,验证电子邮件的格式是否正确。(鑫众人云)

23.请对POSIX风格和兼容Perl风格两种正则表达式的主要函数进行类比说明(腾讯)

主要区别有以下三种:

preg_replace()里面的正则可以写成型如:"/.xxx/"而ereg_replace()里面的正则需写成型如 "xxx"

preg_replace()能操作数组,而ereg_replace()不可以

在逆向引用用preg_replace()可使用0-99个,而ereg_replace()最多为9个

使用Perl兼容正则表达式语法的preg_match()函数通常是比ereg()更快的替代方案。

24.请写出并说明如何在命令行下运行PHP脚本(写出两种方式)同时向PHP脚本传递参数?(腾讯)

首先进入php安装目录
php -f d:/wamp/www/1.php 其中-f参数指定要执行的php文件
php -r phpinfo(); 其中-r表示直接执行php代码,无需写开始结束标记

25.使用正则表达式提取一段标识语言(html或xml)代码段中指定标签的指定属性值(需考虑属性值对不规则的情况,如大小写不敏感,属性名值与等号间有空格等)。此处假设需提取test标签的attr属性值,请自行构建包含该标签的串(腾讯)

编写如下函数:

<?php
    header("content-type:text/html;charset=utf-8");
 
    function getAttrValue($str,$tagName,$attrName){
        $pattern1="/<".$tagName."(\\s+\\w+\s*=\\s*([\\&#39;\\\"]?)([^\\&#39;\\\"]*)(\\2))*\\s+".$attrName."\\s*=\\s*([\\&#39;\\\"]?)([^\\&#39;\\\"]*)(\\5)(\\s+\\w+\\s*=\\s*([\\&#39;\\\"]?)([^\\&#39;\\\"]*)(\\9))*\\s*>/i";
 
        $arr=array();
        $re=preg_match($pattern1,$str,$arr);
 
        if($re){
            echo"<br/>\$arr[6]={$arr[6]}";
        }else{
            echo"<br/>没找到。";
        }
    }
 
    // 示例
    $str1="<test attr=&#39;ddd&#39;>";
    getAttrValue($str1,"test","attr");//找test标签中attr属性的值,结果为ddd
    $str2="<test2 attr=&#39;ddd&#39;attr2=&#39;ddd2&#39;t1=\"t1 value\"t2=&#39;t2 value&#39;>";
    getAttrValue($str2,"test2","t1");//找test2标签中t1属性的值,结果为t1 value
?>
Copy after login

26.What does the following code do?Explain what's going on there.date);(Yahoo)

这是把一个日期从MM/DD/YYYY的格式转为DD/MM/YYYY格式。
输出26/08/2003

27.What function would you use to redirect the browser to a new page?(Yahoo)

A.redir()
B.header()
C.location()
D.redirect()
答案:B
redir()这不是一个PHP函数,会引致执行错误。
header()这个是正确答案,header()函数发送头信息,可以用来使浏览器转向到另一个页面,例如:header("Location:http://www.search-this.com/")。
location()这不是一个PHP函数,会引致执行错误。
redirect()这不是一个PHP函数,会引致执行错误。

28.When turned on____________will_________your script with different variables from
HTML forms and cookies.(腾讯)

A.show_errors,enable
B.show_errors,show
C.register_globals,enhance
D.register_globals,inject
答案:C

29.一个函数的参数不能是对变量的引用,除非在php.ini中把____设为on。
allow_call_time_pass_reference
是否启用在函数调用时强制参数被按照引用传递

30.在HTML语言中,页面头部的meta标记可以用来输出文件的编码格式,以下是一个标准的meta语句,请使用PHP语言写一个函数,把一个标准HTML页面���的类似meta标记中的charset部分值改为big5。(新浪)

请注意:
(1)需要处理完整的html页面,即不光此meta语句
(2)忽略大小写
(3)'和"在此处是可以互换的
(4)'Content-Type'两侧的引号是可以忽略的,但'text/html;charset=gbk'两侧的不行
(5)注意处理多余空格
编写正则表达式如下:
$reg1="/()/i";

31.PHP中如何判断一个字符串是否是合法的日期模式:2007-03-13 13:13:13。要求代码不超过5行。(酷讯)

<?php
    function checkDateTime($data){
        if (date(&#39;Y-m-d H:i:s&#39;,strtotime($data)) == $data) {
            return true;
        } else {
            return false;
        }
    }
 
    // 示例
    $data = &#39;2015-06-20 13:35:42&#39;;
    var_dump(checkDateTime($data));//bool(true)
 
    $data = &#39;2015-06-36 13:35:42&#39;;
    var_dump(checkDateTime($data));//bool(false)
?>
Copy after login

32.PHP中,如何获得一个数组的键值?(酷讯)

使用key()可以获得数组中当前元素的键名,使用current()则可以返回当前元素的值。
使用array_keys()则可以得到数组中所有的键名。
使用foreach结构foreach($arr as value)可以通过value分别获取键名和值。

33.如果模板是用smarty模板。怎样用section语句来显示一个名为$data的组。比如:

$data=array(
0=>array(&#39;id&#39;=>8,&#39;name&#39;=>&#39;name1&#39;),
1=>array(&#39;id&#39;=>10,&#39;name&#39;=>&#39;name2&#39;),
2=>array(&#39;id&#39;=>15,&#39;name&#39;=>&#39;name3&#39;)
);
Copy after login

写出在模板页的代码?若用foreach语句又要怎样显示呢?

用section语句:

<{section name=test loop=$data start=0 step=1}>
id:<{$data[test].id}><br/>
name:<{$data[test].name}><br/><br/>
<{sectionelse}>
数组为空
<{/section}>
Copy after login

用foreach语句:

<{foreach from=$data item=test}>
id:<{$test.id}><br/>
name:<{$test.name}><br/><br/>
<{foreachelse}>
数组为空
<{/foreach}>
Copy after login

34.哪个选项会匹配下边的这个正则表达式?(/.*xyz\d/)
A.*****xyz

B.*****xyz1
C.******xyz2
D.*xyz
答案:C

35.以下哪个错误无法被标准的错误控制器获取?

A.E_WARNING
B.E_USER_ERROR
C.E_PARSE
D.E_NOTICE
答案:B

36.以下哪种错误类型无法被自定义的错误处理器捕捉到?(奇矩互动)

A.E_WARNING
B.E_USER_ERROR
C.E_PARSE
D.E_NOTICE
答案:C

37.(^\s)|(\s$)这个正则表达式作用是:__________;

匹配以0个或多个空白符开头或者0个或多个空白符结尾的字符串

38.编写函数取得上一月的最后一天

<?php
    date_default_timezone_set(&#39;PRC&#39;);
 
    /**
     * 获取给定月份的上一月最后一天
     * @param $date string 给定日期
     * @return string 上一月最后一天
     */
    function get_last_month_last_day($date = &#39;&#39;){
        if ($date != &#39;&#39;) {
            $time = strtotime($date);
        } else {
            $time = time();
        }
        $day = date(&#39;j&#39;,$time);//获取该日期是当前月的第几天
        return date(&#39;Y-m-d&#39;,strtotime("-{$day} days",$time));
    }
 
    // 测试
    echo get_last_month_last_day();
    echo "<br />";
    echo get_last_month_last_day("2013-3-21");
?>
Copy after login

39.在很多时候,我们可以通过apache的主配置文件来设置对test目录的访问权限控制,如http://IP/test请问如果需设置test下的一个子目录的访问控制权限,是否可以在主配置文件中修改,如果不可以应如何解决

可以,还可以在需要控制的子目录下创建.htaccess文件,写入访问控制。

40.如果我的网站用的utf-8编码,为防止乱码出现,都需要注意哪些地方?

从以下几个方面考虑:

数据库中库和表都用utf8编码

php连接mysql,指定数据库编码为utf8 mysql_query(“set names utf8”);

php文件指定头部编码为utf-8header(“content-type:text/html;charset=utf-8”);

网站下所有文件的编码为utf8

html文件指定编码为utf-8

41.在url中用get传值的时候,若中文出现乱码,应该用哪个函数对中文进行编码?

urlencode()

42.写出两种对变量加密的函数?

md5(str);

43.如何把2009-9-2 10:30:25变成unix时间戳?

<?php
    date_default_timezone_set("PRC");
 
    // 将字符串转成Unix时间戳
    $unix_time = strtotime("2009-9-2 10:30:45");
    echo $unix_time;
    echo "<br />";
 
    // 格式化Unix时间戳为正常时间格式
    echo date("Y-m-d H:i:s",$unix_time);
?>
Copy after login

44.如何把一个GB2312格式的字符串装换成UTF-8格式?

<?php
    iconv(&#39;GB2312&#39;,&#39;UTF-8&#39;,&#39;悄悄是别离的笙箫&#39;);
?>
Copy after login

45.如果需要原样输出用户输入的内容,在数据入库前,要用哪个函数处理?

htmlspecialchars或者htmlentities

46.写出五种以上你使用过的PHP的扩展的名称(提示:常用的PHP扩展)

mb_sring、iconv、curl、GD、XML、socket、MySQL、PDO等

47.了解MVC模式吗?请写出三种以上目前PHP流行的MVC框架名称(不区分大小写)

FleaPHP、Zend Framework、CakePHP、Symfony、ThinkPHP、YII、CodeIgniter等

48.php中WEB上传文件的原理是什么,如何限制上传文件的大小?

上传文件的表单使用post方式,并且要在form中添加enctype='multipart/form-data'。
一般可以加上隐藏域:,位置在file域前面。
value的值是上传文件的客户端字节限制。可以避免用户在花时间等待上传大文件之后才发现文件过大上传失败的麻烦。
使用file文件域来选择要上传的文件,当点击提交按钮之后,文件会被上传到服务器中的临时目录,在脚本运行结束时会被销毁,所以应该在脚本结束之前,将其移动到服务器上的某个目录下,可以通过函数move_uploaded_file()来移动临时文件,要获取临时文件的信息,使用$_FILES。

限制上传文件大小的因素有:

客户端的隐藏域MAX_FILE_SIZE的数值(可以被绕开)。

服务器端的upload_max_filesize,post_max_size和memory_limit。这几项不能够用脚本来设置。

自定义文件大小限制逻辑。即使服务器的限制是能自己决定,也会有需要个别考虑的情况。所以这个限制方式经常是必要的。

49.简述UBB code的实现原理。(YG)

UBB代码是HTML的一个变种,通过程序自定义我们的标签,比如“[a]PHP中UBB的使用[/a]”这样的标签,其实质就是查找[a][/a]标签,将其替换成的标准html,说白了,就是将标准的html标记通过技术手段使其简化,其输出出来的结果还是标准的html。
明白了ubb的原理,那么再制作一个简单的ubb编辑器就不难了,和fck之类的编辑器比较起来,ubb代码最大的优点就是代码简单,功能很少,简单的ubb只需要一个文件,而且ubb标签可以自己来定义,更改起来很方便,在php中就是利用替换函数就可以将
html进行标签化,输出时进行标签的转化。

50.怎么把文件保存到指定目录?怎么避免上传文件重名问题?

可以自己设置上传文件的保存目录,与文件名拼凑形成一个文件路径,使用move_uploaded_file(),就可以完成将文件保存到指定目录。
可以通过上传的文件名获取到文件后缀,然后使用时间戳+随机数+文件后缀的方式为文件重新命名,这样就避免了重名。

51._____函数能返回脚本里的任意行中调用的函数的名称。该函数同时还经常被用在调试中,用来判断错误是如何发生的。(奇矩互动)

debug_print_backtrace()

52.在Smarty模板语法中怎么能遍历数组ids

{section name=temp loop=$ids}
    {if $ids[temp].id==500}
        <span style=‘color:#f00;’>{$ids[temp].id}</span>
    {esle}
        {$ids[temp].id}
    {/if}
{/section}
Copy after login

53.在Smarty模板语法中如何获取当前时间,并且使用Y-m-d H:i:s的格式输出?(亿邮)

使用{$smarty.now}来获取当前时间,得到的是unix系统时间戳
使用变量调节器进行格式化,如下:

{$smarty.now|date_format:“%Y-%m-%d%H:%M:%S”}
Copy after login

54.在Smarty模板语法中如何获取php的全局环境变量(亿邮)

$smarty.get.变量 #显示通过get方式传过来的指定变量的值
$smarty.post.变量 #显示通过post方式传过来的指定变量的值
$smarty.cookies.变量 #显示通过cookie中指定变量的值
$smarty.server.SERVER_NAME #显示server变量值,$_SERVER系列变量
$smarty.env.PATH #显示系统环境变量值,$_ENV系列变量
$smarty.session.变量 #显示session中指定变量的值
$smarty.request.变量 #显示通过post、get、cookie中指定变量的值

55.在Smarty模板中如何用自定义函数(亿邮)

使用模板分隔符包含,传递参数则使用HTML属性的方式,例如:
{html_image file="pumpkin.jpg"}

56.列举出你所知道的php系统函数库例如,数学函数库(亿邮)

mysql,gd,pdo,XML,zip,filesystem,mail等

57.假如让你来写一个函数实现Utf-8转gb2312,那么函数的名称应该怎么命名?(亿邮)

utf8_to_gb2312或者utf8togb2312

58.请描述如下URL重写规则的用意。(卓望)

<IfModulemod_rewrite.c>
RewriteEngineon
RewriteCond%{REQUEST_FILENAME}!-f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteBase/
RewriteRule./index.php[L]
</IfModule>
Copy after login

如果REQUEST_FILENAME文件存在,就直接访问文件,不进行下面的rewrite规则,
如果REQUEST_FILENAME目录存在,就直接访问目录,不进行下面的rewrite规则,
RewriteRule./index.php[L]的意思是把所有的请求都给index.php处理。

59.Warning:Cannot modify header information-headers already sent by(output started at D:\src\init.php:7)in D:\src\init.php on line10通常什么情况下php会报该警告信息?(卓望)

一般是在header、set_cookie以及session_start函数前面有输出(包括空格)的情况下,会报该警告信息

The above is the detailed content of 2018php latest interview questions PHP core technology. For more information, please follow other related articles on the PHP Chinese website!

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!