background image

面试题 1

1、用 PHP 打印出前一天的时间格式是 2006-5-10 22:21:21
echo   date("Y-m-d   H:i:s",time()-(3600*24));

echo   date("Y-m-d 

H:i:s",strtotime("-1 day"));
2、echo(),print(),print_r()的区别

echo 可以接多个参数,print 只能接一个参数,它们都是 PHP 的语言结构,print_r 是递规

打印,用来打印数组或对象

3、能够使 HTML 和 PHP 分离开使用的模板
smarty,phplib,SmartTemplate

4、如何实现 PHP、JSP 交互?
PHP 提供了支持 JAVA 的类库文件,或者通过 HTTP 协议来交互数据

5、使用哪些工具进行版本控制?
VSS,CVS,SVN

6、如何实现字符串翻转?

不考虑中英文混合,不是最优算法,不用 php 库函数翻转字符串:

function   str_to_reverse(   $str   ){   
    for($length=0;$str[$length]!=null;$length++){;}   

  $strlength   =   $length-1;   
  unset($length);   

    
  for($start=0,$end=$strlength;$start<$end;$start++,$end--){   

  $temp   =   $str[$start];   
  $str[$start]   =   $str[$end];   

  $str[$end]   =   $temp;   
  }   

  unset($temp,$start,$end,$strlength);   
  return   $str;   

  }   

7、优化 MYSQL 数据库的方法。
1 将 where 中用的比较频繁的字段建立索引,联合索引。

2 保证单表数据不超过 200W,适时分割表。

3 避免使用长连接。

4 修改 my.cnf 里面的各项参数,比如最大连接数,查询缓存等。根据你的服务器内存来

最大化调节那些配置参数。

5 针对需求,使用正确的表引擎,是 myisam 或是 innodb。

 

 

8.用 PHP 写出显示客户端 IP 与服务器 IP 的代码:
echo $_SERVER['REMOTE_ADDR'] //客户端 ip

echo $_SERVER['SERVER_ADDR'] //服务器端 ip

 

9、apache+mysql+php 实现最大负载的方法
1 问的太笼统,生成静态 html 页面,squid 反向代理,apache,mysql 的负载均衡。