复制代码
结果 1 int和string类型强制转换造成的,0===a
0 == 0 肯定是true啊php是弱类型。。$tmp = 0 === a? 1: 2;echo $tmp; 这样就是2
4. 已知一个字符串如下: $str = 1109063 milo 1;用一行代码将该字符串里面的1109063赋值给$uid, milo赋值给$user, 1赋值给$type空格如下list($uid, $user, $type) = explode( , $str);\t如下list($uid, $user, $type) = explode(\t, $str);list($uid, $user, $type) = sscanf($str, %d %s %d);$n = sscanf($auth, %d\t%s %s, $id, $first, $last);
5. 分别列出如下类型的有符号和无符号范围 tinyint smallint mediumint inttinyint-2^7 - 2^7-10 ~ 2^8-1smallint-2^15 - 2^15-1 0 ~ 2^16-1mediumint-2^23 - 2^23-1 0 ~ 2^24-1int-2^31 - 2^31-1 0 ~ 2^32-1
6. 将下面的数组用一行拼装成一个字符串i am milo! day day up!
$str = strtolower(implode( ,$arr));
复制代码
7. 调用如下函数获取函数并获取count的值
$count=1;$data = get_list($cnd,&$count);echo $count;
复制代码
8. 几种方式去取代session机制, 简单描述各自的优劣mysql、memcache、cookie保持一种唯一状态标识码
9. 下列http状态码出现的可能原因, 如何处理200, 301, 404, 502, 503200请求已成功,请求所希望的响应头或数据体将随此响应返回。301被请求的资源已永久移动到新位置,并且将来任何对此资源的引用都应该使用本响应返回的若干个 uri 之一。如果可能,拥有链接编辑功能的客户端应当自动把请求的地址修改为从服务器反馈回来的地址。除非额外指定,否则这个响应也是可缓存的。 新的永久性的 uri 应当在响应的 location 域中返回。除非这是一个 head 请求,否则响应的实体中应当包含指向新的 uri 的超链接及简短说明。 如果这不是一个 get 或者 head 请求,因此浏览器禁止自动进行重定向,除非得到用户的确认,因为请求的条件可能因此发生变化。
注意:对于某些使用 http/1.0 协议的浏览器,当它们发送的 post 请求得到了一个301响应的话,接下来的重定向请求将会变成 get 方式。
404请求失败,请求所希望得到的资源未被在服务器上发现。没有信息能够告诉用户这个状况到底是暂时的还是永久的。假如服务器知道情况的话,应当使用410状态码来告知旧资源因为某些内部的配置机制问题,已经永久的不可用,而且没有任何可以跳转的地址。404这个状态码被广泛应用于当服务器不想揭示到底为何请求被拒绝或者没有其他适合的响应可用的情况下。502作为网关或者代理工作的服务器尝试执行请求时,从上游服务器接收到无效的响应。503由于临时的服务器维护或者过载,服务器当前无法处理请求。这个状况是临时的,并且将在一段时间以后恢复。如果能够预计延迟时间,那么响应中可以包含一个 retry-after 头用以标明这个延迟时间。如果没有给出这个 retry-after 信息,那么客户端应当以处理500响应的方式处理它。 注意:503状态码的存在并不意味着服务器在过载的时候必须使用它。某些服务器只不过是希望拒绝客户端的连接。
200 ok 一切正常,对get和post请求的应答文档跟在后面。301 moved permanently 客户请求的文档在其他地方,新的url在location头中给出,浏览器应该自动地访问新的url404 not found 无法找到指定位置的资源。这也是一个常用的应答。502 bad gateway 服务器作为网关或者代理时,为了完成请求访问下一个服务器,但该服务器返回了非法的应答。503 service unavailable 服务器由于维护或者负载过重未能应答。例如,servlet可能在数据库连接池已满的情况下返回503。服务器返回503时可以提供一个retry-after头。
10. 有如下数据库, 用原生态mysql扩展去连接并查询user表的前十行host: 192.168.0.254port: 3306user: onepass: piecedatabase: db_usertable: useraction = lcfirst(implode(array_map(
'ucfirst',explode('-', strtolower($request->action)))));------------------------------------------------function __autoload($class){$cls = strtolower(str_replace(_,/,$class));
if(file_exsits(lib.$cls.'.php')){include_once(lib.$cls.'.php');}else{die(not found {$class} class);}}defined(lib,'/data/wwwroot/www.xx.com/lib/');$author = new lib_author();-----------------------------------------------------------function __authload($class){$cls = explode(_,$class);if(@is_dir($cls[1])){if(@is_file($cls[2])){include_once(con_path.$cls[1].'/'.$cls[2]..php);}else{dir('error');}}else if(@is_file($cls[1]..php)){include_once(con_path.$cls[1]..php);}else{dir('error');}}---------------------------------------function __autoload($class){$cls = explode(_,$class);$file = get_file($cls);if($file=='error'){die('error');}include_once($file);}function get_file($dir){if(is_array($dir)){foreach($dir as $k=>$v){$tmpdir .= $v.'/';if(is_dir('con_path'.$tmpdir)){continue();}else if(is_file('con_path'.$tmpdir..php)){return 'con_path'.$tmpdir..php;}else{return 'error';}}return 'error';}return 'error';}defined(con_path,/data/wwwroot/www.xx.com/app/cntroller/);
$sb = new controller_sb();------------------------------------function __autoload_my_classes($classname){# ... your logic to include classes here}spl_autoload_register('__autoload_my_classes');-----------------------------------------------------------
复制代码
12. 用set_error_handle 去捕获错误并输出, 级别自己定
set_error_handle(callback,level)
function callback(int $errno , string $errstr [, string $errfile [, int $errline [, array $errcontext ]]] ){}function dealerrorhandler($errno,$errstr,$errfile,$errline)
{switch($errno){case e_user_error:echo error [$errno] $errstr fatal error on line $errline in file $errfile;break;case e_user_warning:echo my warning [$errno] $errstr:break;case e_user_notice:echo my notice[$errno] $errstr;break;default:echo unkonwn error type :[$errno] $errstr;break;}}set_erro_handler(dealerrorhandler);trigger_error(notice, e_user_notice);
trigger_error(warning, e_user_warning);trigger_error(error, e_user_error);
复制代码
13. 简述两种屏蔽php程序的notice警告的方法初始化变量,文件开始设置错误级别或者修改php.ini 设置error_reportingset_error_handler 和 @抑制错误
1.在程序中添加:error_reporting (e_all & ~e_notice);2.或者修改php.ini中的:error_reporting = e_all改为:error_reporting = e_all & ~e_notice3.error_reporting(0);或者修改php.inidisplay_errors=off 1 2 3 4 下一页 尾页