獲取文件擴展名
<?php
header ( "Content-Type: text/html; charset=UTF-8" );
// function get_extension($filename){
// return substr(strrchr($filename,"."),1);
// }
// function get_extension($filename){
// return substr($filename,strrpos($filename,".")+1);
// }
// function get_extension($filename){
// $filearray=explode(".",$filename);
// return end($filearray);
// }
function get_extension($filename){
return $fileinfo=pathinfo($filename,PATHINFO_EXTENSION);
}
//....
02
$tempfile = @fopen($img, "rb");
03
$bin= fread($tempfile, 2); //只讀2字節
04
fclose($tempfile);
05
$strInfo = @unpack("C2chars", $bin);
06
$typeCode = intval($strInfo['chars1'] . $strInfo['chars2']);
07
$fileType = '';
08
switch($typeCode){ // 6677:bmp 255216:jpg 7173:gif 13780:png 7790:exe 8297:rar 8075:zip tar:109121 7z:55122 gz 31139
09
case '255216':
10
$fileType = 'jpg';
11
break;
12
case '7173':
13
$fileType = 'gif';
14
break;
15
case '13780':
16
$fileType = 'png';
17
break;
18
default:
19
$fileType = 'unknown';
20
}
21
//....
echo get_extension("uolpad.php");
?>
實現中文字符串截取的PHP實現方法
用最少的代碼寫一個求三個數最大值的函數
php如何取得當前運行腳本所在的文檔目錄
請用正則表達式寫一個函數驗證電子郵件的模式是否正確
使用三種以上的方式獲取文件擴展名
求兩個日期的差數,例如2007-2-5到2007-3-6的日期差數
echo count("abc") 結果是1.count()函數對於數組,返回其元素的個數,對於其它值,返回1.
開發過程中用什麼方法來加快頁面的加載速度?答:要用到服務器資源時才打開,及時關閉服務器資源,建立數據庫索引,頁面生成靜態,圖片等大文件單獨存儲服務器,代碼優化工具。
PHP面向對象中__set()與__toString()的作用。http://www.cnblogs.com/glory-jzx/archive/2012/05/23/2514173.html
常見的http協議及提示代表什麼意思?http://blog.sina.com.cn/s/blog_4ea497b70100tlq4.html
網絡協議有哪些?TCP/IP,FTP,HTTP
php性能優化策略有哪些?http://www.jb51.net/article/24248.htm