Time of Update: 2016-07-25
//$file_path=iconv("utf-8","gb2312","C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\樣本圖片\\完全達到.jpg"); /* if(!copy("C:\\Winter.jpg","D:\\aa.jpg")){ echo "error"; }else{ echo "OK"; } */ //中文要進行轉碼,否則就會報錯
Time of Update: 2016-07-25
/** * php時間 date函數應用 * edit bbs.it-home.org*/echo "今天:".date("Y-m-d")."";echo "昨天:".date("Y-m-d",strtotime("-1 day")), "";echo "明天:".date("Y-m-d",strtotime("+1 day")). "";echo "一周后:".date("Y-m-d",strtotime("+1 week")). "";echo "一周零兩天四小時兩秒後:".date("Y-
Time of Update: 2016-07-25
/* @creates a compressed zip file 將多個檔案壓縮成一個zip檔案的函數 * @$files 數群組類型 執行個體array("1.jpg","2.jpg"); * @destination 目標檔案的路徑 如"c:/androidyue.zip" * @$overwrite 是否為覆蓋與目標檔案相同的檔案 * @site http://bbs.it-home.org */
Time of Update: 2016-07-25
/*** 遍曆目錄,結果存入數組。支援php4及以上。php5以後可用scandir()函數代替while迴圈。* @param string $dir* @return array*/my_scandir($dir){$files = array();if ( $handle = opendir($dir) ){while ( ($file = readdir($handle)) !== false ){if ( $file != ".." && $file != "." ){if ( is_
Time of Update: 2016-07-25
$string = '0123456789abcdefghijklmnopqrstuvwxyz';$length = strlen($string);function makeDir($param){if(!file_exists($param)) {echo "mkdir ".$param."\n”;exec("mkdir ".$param);}}for($i = 0; $i for($j = 0; $j makeDir('/data/session_tmp/'.$string[$i].'/'
Time of Update: 2016-07-25
while (list($k,$v) = each($data)) {$encoded .= ($encoded ? "$sep" : "");$encoded .= rawurlencode($k)."=".rawurlencode($v);}Return $encoded;}Function post($url, $post, $cookie){$url = parse_url($url);$post = encode($data, ‘&’);$cookie =
Time of Update: 2016-07-25
//開啟檔案$file_path="text.txt";if($fp=fopen($file_path,"r")){ //取出檔案的資訊 $file_info=fstat($fp); echo ""; print_r($file_info); echo ""; //單個的取出 $file_size=$file_info['size']; //檔案大小按位元組來計算的 echo "檔案的大小為:".$file_size; echo
Time of Update: 2016-07-25
function GBsubstr($string, $start, $length) { if(strlen($string)>$length){ $str=null; $len=$start+$length; for($i=$start;$i if(ord(substr($string,$i,1))>0xa0){ $str.=substr($string,$i,2); $i++; }else{
Time of Update: 2016-07-25
@ $fp=fopen("http://bbs.it-home.org/abc123",'w');if (!$fp){ echo'檔案不存在'; exit;}?>
Time of Update: 2016-07-25
class my_class{function my_funct ($my_param){user_error ("please define me", E_ERROR);}function b(){return 10;}}?>複製代碼A.多重繼承B.介面C.抽象方法D.private 方法E.函數重載(function overloading)7. 假設定義了一個 testclass
Time of Update: 2016-07-25
//讀取檔案 $file_path="text.txt"; if(!file_exists($file_path)){ echo "檔案不存在"; exit(); } //開啟檔案 $fp=fopen($file_path,"a+"); //讀取檔案 $content=fread($fp,filesize($file_path)); echo "檔案內容是:";
Time of Update: 2016-07-25
$m=$_GET['m'];$user=$_GET['user'];$pass=$_GET['pass'];$include($m.”do/php”);$sql=”select count(*) as b from user where username=’”.$user.”‘and password=’”.$pass.”‘;$r=mysql_query($sql);list($count)=@mysql_fetch_array($r);if($count>1){……登陸成功操作}?>複製代碼3
Time of Update: 2016-07-25
mysql_query("BEGIN"); mysql_query("INSERT INTO customerinfo (name) VALUES ('$name1')"; mysql_query("SELECT * FROM `orderinfo` where customerid=".$id"); mysql_query("COMMIT");複製代碼5)、鎖定表,最佳化交易處理: a.我們用一個 SELECT 語句取出初始資料,通過一些計算,用 UPDATE
Time of Update: 2016-07-25
$filename = "/usr/local/something.txt"; $handle = fopen($filename, "r");//讀取二進位檔案時,需要將第二個參數設定成'rb' //通過filesize獲得檔案大小,將整個檔案一下子讀到一個字串中 $contents = fread($handle, filesize ($filename)); fclose($handle);?>
Time of Update: 2016-07-25
function strrev($str) {$len=strlen($str);$newstr = ' ';for($i=$len;$i> =0;$i--){$newstr .= $str{$i};}return $newstr;}複製代碼7、資料庫相關(1).資料庫設計方面,這是DBA和Architect的責任,設計結構良好的資料庫,必要的時候,去正規化(英文是這個:denormalize,中文翻譯成啥我不知道),允許部分資料冗餘,避免JOIN操作,以提高查詢效率(
Time of Update: 2016-07-25
/** * php 檔案編程 寫入檔案 * edit bbs.it-home.org*/ //寫檔案 $file_path="text.txt"; if(!file_exists($file_path)){ echo "檔案不存在"; exit(); } //"a+" 在檔案後面追加 "w+"重新寫入 $fp=fopen($file_path,"w+"); $con="\r\n你好"; for($i=0;$i
Time of Update: 2016-07-25
//產生HTML$countfile="template.html";$num=file_get_contents($countfile);echo $num;$num=str_replace("|*|*|PAGE_TITLE|*|*|","myhome",$num);$path="template.html";$handle=fopen($path,"w"); //寫入方式開啟新聞路徑fwrite($handle,$num);
Time of Update: 2016-07-25
本文介紹下,一份據說是新浪公司的php程式員面試題,有需要的朋友,參考下吧。新浪PHP工程筆試題1. 寫一個函數,儘可能高效的,從一個標準 url 裡取出檔案的副檔名 例如: http://www.sina.com.cn/abc/de/fg.php?id=1 需要取出 php 或 .php2. 在 HTML 語言中,頁面頭部的 meta 標記可以用來輸出檔案的編碼格式,以下是一個標準的 meta 語句 請使用 PHP 語言寫一個函數,把一個標準 HTML 頁面中的類似 meta
Time of Update: 2016-07-25
$str1 = null;$str2 = false;echo $str1==$str2 ? ‘相等’ : ‘不相等’;$str3 = ”;$str4 = 0;echo $str3==$str4 ? ‘相等’ : ‘不相等’;$str5 = 0;$str6 = ’0′;echo $str5===$str6 ? ‘相等’ : ‘不相等’;?>複製代碼2. 寫出如下程式的輸出結果 $a1 = null;$a2 = false;$a3 = 0;$a4 = ”;$a5 = ’0′;$a6 =
Time of Update: 2016-07-25
/*** php 面試題* edit bbs.it-home.org* at 2013-05-13*/functiongbk_strrev($str){//----gbk中文字串翻轉-----$len=strlen($str); for($i=0;$i $char=$str{0}; if(ord($char)>127){ $i++; if($i $arr[]=substr($str,0,2);