您的位置 首页 php

PHP面试题汇总(附答案)

推荐学习《2019年PHP面试题大汇总(收藏)》

1.表单中 get与post提交方法的区别?

答:get是发送请求HTTP协议通过url参数传递进行接收,而post是实体数据,可以通过表单提交大量信息.

2.session与cookie的区别?

答:

session:储存用户访问的全局唯一变量,存储在服务器上的php指定的目录中的(session_dir)的位置进行的存放

cookie:用来存储连续訪問一个頁面时所使用,是存储在客户端,对于Cookie来说是存储在用户WIN的Temp目录中的。

两者都可通过时间来设置时间长短

3.数据库中的事务是什么?

答:事务(transaction)是作为一个单元的一组有序的数据库操作。如果组中的所有操作都成功,则认为事务成功,即使只有一个操作失败,事务也不成功。如果所有操作完成,事务则提交,其修改将作用于所有其他数据库进程。如果一个操作失败,则事务将回滚,该事务所有操作的影响都将取消。

简述题:

1、用PHP打印出前一天的时间格式是2006-5-10 22:21:21(2分)****************

答:echo date('Y-m-d H:i:s', strtotime('-1 days'));

2、echo(),print(),print_r()的区别(3分)

答:

echo、print是语言结构,print_r是函数,语句没有返回值,函数可以有返回值(即便没有用)

print() 只能打印出简单类型变量的值(如int,string)

print_r()可以打印出复杂类型变量的值(如数组,对象)

echo 输出一个或者多个字符串

3、能够使HTML和PHP分离开使用的模板(1分)

答:Smarty,Dwoo,TinyButStrong,Template Lite,Savant,phemplate,XTemplate

4、使用哪些工具进行版本控制?(1分)

答:cvs,svn,vss;

5、如何实现字符串翻转?(3分)

答:echo strrev($a);

6、优化MYSQL数据库的方法。(4分,多写多得)

答:

1、选取最适用的字段属性,尽可能减少定义字段长度,尽量把字段设置NOT NULL,例如'省份,性别',最好设置为ENUM

2、使用连接(JOIN)来代替子查询:

3、使用联合(UNION)来代替手动创建的临时表

4、事务处理:

5、锁定表,优化事务处理:

6、使用外键,优化锁定表

7、建立索引:

8、优化查询语句

7、PHP的意思(送1分)

答:PHP是一个基于服务端来创建动态网站的脚本语言,您可以用PHP和HTML生成网站主页

8、MYSQL取得当前时间的函数是?,格式化日期的函数是(2分)

答:now(),date()

9、实现中文字串截取无乱码的方法。(3分)****************

Mb_substr

答:

function GBsubstr($string, $start, $length) {    if(strlen($string)>$length){     $str=null;     $len=$start+$length;     for($i=$start;$i<$len;$i++){    if(ord(substr($string,$i,1))>0xa0){     $str.=substr($string,$i,2);     $i++;    }else{     $str.=substr($string,$i,1);     }    }   return $str.'...';    }else{   return $string;   }}

10、您是否用过版本控制软件? 如果有您用的版本控制软件的名字是?(1分)

答:用过,cvs,svn,vss

11、您是否用过模板引擎? 如果有您用的模板引擎的名字是?(1分)

答:用过,smarty

12、请简单阐述您最得意的开发之作(4分)

答:信息分类

13、对于大流量的网站,您采用什么样的方法来解决访问量问题?(4分)

答:

确认服务器硬件是否足够支持当前的流量,数据库读写分离,优化数据表,

程序功能规则,禁止外部的盗链,控制大文件的下载,使用不同主机分流主要流量

14、用PHP写出显示客户端IP与服务器IP的代码1分)

答:打印客户端IP:

echo $_SERVER[‘REMOTE_ADDR’];// 或者: getenv('REMOTE_ADDR');// 打印服务器IP:echo gethostbyname("www.bolaiwu.com")

15、语句include和require的区别是什么?为避免多次包含同一文件,可用(?)语句代替它们? (2分)

答:require->require是无条件包含也就是如果一个流程里加入require,无论条件成立与否都会先执行require

include->include有返回值,而require没有(可能因为如此require的速度比include快)

注意:包含文件不存在或者语法错误的时候require是致命的,include不是

16. 在PHP中error_reporting这个函数有什么作用? (1分)

答:设置错误级别与错误信息回报

17. 请写一个函数验证电子邮件的格式是否正确 (2分)

答:

function checkEmail($email){    $pregEmail = "/([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?/i";    return preg_match($pregEmail,$email);  }

18. 简述如何得到当前执行脚本路径,包括所得到参数。(2分)

答:

$script_name = basename(__file__); print_r($script_name);

以上就是PHP面试题汇总(附答案)的详细内容,更多请关注求知技术网其它相关文章!

文章来源:智云一二三科技

文章标题:PHP面试题汇总(附答案)

文章地址:https://www.zhihuclub.com/3102.shtml

关于作者: 智云科技

热门文章

评论已关闭

24条评论

  1. There will be time enough for them to discover cinemaГў I want her free of syntetic hormones and spirilactone

  2. Here is my problem If you wait too long to get more information, someone else will have introduced the legislation

  3. Circulating myeloid derived suppressor cells increase in patients undergoing neo adjuvant chemotherapy for breast cancer I have a 32 year old son who just got married this past Nov

  4. HLA DRB1 alleles in Egyptian children with post streptococcal acute glomerulonephritis Francoz C, Glotz D, Moreau R, Durand F 2010 The evaluation of renal function and disease in patients with cirrhosis

  5. In many cases, your doctor may recommend a drug you can buy over the counter OTC at your local drugstore

  6. That s it, Elder Hughes, top 10 best blood pressure medicine the elves have too many old rules, they love peace and life too much

  7. Veterinary Vaccines and Diagnostics Preterm neonates have proportionally more water at 23 weeks gestation, the body is 90 water; 60 ECF and 30 ICF, and they may lose 10 15 of their weight in the first week of life

  8. Young patients with ultralow or low AMH with diminished ovarian reserve have higher pregnancy rates than the 44 year olds with the same AMH

  9. Early work by Lednicer in the 1960s 161 concluded that the presence of a basic group at a given position in space is required to obtain a molecule, which will antagonize the effects of concurrent estrogen administration

  10. For example, seafood such as salmon, sardines, and shellfish are rich in omega 3 and contain many minerals to alleviate the symptoms

  11. I am not a doctor but a mother of a child who spent thousands of dollars to get here 0 mL was added compound 199

  12. Sometimes this is a self limiting disease My first, 14dpo, came back 21 which is pretty low but they considered it pregnant, the second came back 56 still low but more than doubled in 48 hours, and I m going in today for a third even though OB doesn t seem concerned with how low the numbers are, I m really hoping 18dpo are much higher

网站地图