Time of Update: 2016-07-29
複製代碼 代碼如下:// 定義變數 $local_file = 'local.zip'; $server_file = 'server.zip'; // 串連FTP伺服器 $conn_id = ftp_connect($ftp_server); //驗證登入伺服器 $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // 下載檔案 if (ftp_get($conn_id, $local_file,
Time of Update: 2016-07-29
複製代碼 代碼如下:/********************** *@file - path to zip file *@destination - destination directory for unzipped files */ function unzip_file($file, $destination){ // create object $zip = new ZipArchive() ; // open archive if ($zip->open($file) !==
Time of Update: 2016-07-29
php ftp傳送檔案到伺服器 複製代碼 代碼如下:// 開始 $ret = ftp_nb_get ($my_connection, "test", "README", FTP_BINARY, filesize("test")); // 或: $ret = ftp_nb_get ($my_connection, "test", "README", // FTP_BINARY, FTP_AUTORESUME); while ($ret == FTP_MOREDATA) { // 可以插入其它代碼
Time of Update: 2016-07-29
set_time_limit(0); 括弧裡邊的數字是執行時間,如果為零說明永久執行直到程式結束,如果為大於零的數字,則不管程式是否執行完成,到了設定的秒數,程式結束。 一個簡單的例子,在網頁裡顯示1500條語句,如果未設定失效時間,則程式執行到791時結束了,如果把 set_time_limit(0); 前的注釋符//去除,則程式直到1才結束。 複製代碼 代碼如下://set_time_limit(0); $i=1500; include ("inc/conn.php"); while($i>
Time of Update: 2016-07-29
複製代碼 代碼如下:/* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return
Time of Update: 2016-07-29
複製代碼 代碼如下:** * 寫檔案 * @param string $file 檔案路徑 * @param string $str 寫入內容 * @param char $mode 寫入模式 */ function writeFile($file,$str,$mode='w') { $oldmask = @umask(0); $fp = @fopen($file,$mode); @flock($fp, 3); if(!$fp) { Return false; } else { @fwrite(
Time of Update: 2016-07-29
複製代碼 代碼如下:function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 ) { $minimumCount = min( array_values( $data ) ); $maximumCount = max( array_values( $data ) ); $spread = $maximumCount - $minimumCount; $cloudHTML = ''; $cloudTags =
Time of Update: 2016-07-29
百度查閱了一些資料,再結合自己的一些經驗,採用以下解決辦法: 複製代碼 代碼如下:$idlist=''; for($i=1;$iif($i==1){ $idlist=mt_rand(3,25216); } else{ $idlist=$idlist.','.mt_rand(3,25216); } } $query="select * from table where id in ($idlist) LIMIT 0,10";
Time of Update: 2016-07-29
複製代碼 代碼如下:/******************** *@file - path to file */ function force_download($file) { if ((isset($file))&&(file_exists($file))) { header("Content-length: ".filesize($file)); header('Content-Type: application/octet-stream');
Time of Update: 2016-07-29
說明 array array_flip ( array trans ) array_flip() 返回一個反轉後的 array,例如 trans 中的鍵名變成了值,而 trans 中的值成了鍵名。 注意 trans 中的值需要能夠作為合法的鍵名,例如需要是 integer 或者 string。如果值的類型不對將發出一個警告,並且有問題的鍵/值對將不會反轉。 如果同一個值出現了多次,則最後一個鍵名將作為它的值,所有其它的都丟失了。 array_flip() 如果失敗返回
Time of Update: 2016-07-29
複製代碼 代碼如下:/********************** *@filename - path to the image *@tmpname - temporary path to thumbnail *@xmax - max width *@ymax - max height */ function resize_image($filename, $tmpname, $xmax, $ymax) { $ext = explode(".", $filename); $ext = $ext[
Time of Update: 2016-07-29
複製代碼 代碼如下:function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)','\1\2', $text); $text = eregi_replace('([_.0
Time of Update: 2016-07-29
ezSQL 下載地址: 下載 : ezSQL 新版本是2.05添加了很多支援,包括 CodeIgniter,MSSQL, PDO 等等 我之前也為 CodeIgniter 寫過一次,不過只支援 MySQL 看看使用樣本其實也沒什麼難度,直接看原始碼即可,主要是程式設計的思想很好。 Example 1 ---------------------------------------------------- // Select multiple records from the database
Time of Update: 2016-07-29
寫入過程複製代碼 代碼如下:// Get the path of the configuration file $fname = JPATH_CONFIGURATION.DS.'configuration.php'; // clear cache $cache = JFactory::getCache(); $cache->clean(); // Update the credentials with the new settings $config =&
Time of Update: 2016-07-29
網上有很多php檔案上傳的類,檔案上傳處理是php的一個特色(至少手冊上是將此作為php特點來展示的,個人認為php在數組方面的優異功能更有特色),學php的人都知道檔案上傳怎麼做,但很多人在編程中卻可能忽視了一些細節問題,那就是檔案的類型(MIME)。在表單將檔案提交給php做處理之前,瀏覽器會先解析識別一邊是什麼類型的檔案,之後進入php處理環節,php又會去識別解析此檔案的原始類型(並不是說你改成什麼尾碼就是什麼檔案)。在這個過程中會有一些瀏覽器安全色,更準確來說是檔案類型解析標識不一致的
Time of Update: 2016-07-29
因為我把php升級到了5.3.1,以前的phpmyadmin版本不能用了,就升級到phpMyAdmin 3.2.4版的時候,會遇到無法以空密碼登入root使用者的情況。怎麼解決呢? 請參照如下步驟: 1、開啟程式所在的目錄 2、找到libraries目錄下的config.default.php檔案把 $cfg['Servers'][$i]['AllowNoPassword'] = false;修改成 $cfg['Servers'][$i]['AllowNoPassword'] =
Time of Update: 2016-07-29
複製代碼 代碼如下:$cfg_dbhost ='localhost';//mysql主機 $cfg_dbname ='sq_test';//資料庫名 $cfg_dbuser ='root';//資料庫使用者名稱 $cfg_dbpwd ='jb51.net';//資料庫使用者密碼 $cfg_db_language ='utf8';//資料庫編碼 class dbmysql{ public static $dbhost = 'localhost'; public static $dbname;
Time of Update: 2016-07-29
在web開發中經常會碰到一些簡單的視頻播放功能,但現在的視頻格式不同,並且可以動態增加,所以我們就必須把視頻儲存到資料哦,好了下面我們來看我寫的段簡單的 php視頻網頁播放器代碼吧。 複製代碼 代碼如下:include './admin/connect.php'; @extract($db->get_one("select * from movieinfo where.$_GET['id']."'")); $db->query("update movieinfo set
Time of Update: 2016-07-29
PHP 提供了一個極少使用的 similar_text 函數,但此函數非常有用,用於比較兩個字串並返回相似程度的百分比,以下是similar_text () 函數的使用方法: 複製代碼 代碼如下:similar_text($string1, $string2, $percent); //使用此函數後,我們從變數$percent 中擷取剛比較的兩個字串的相似性百分比
Time of Update: 2016-07-29
//儲存圖片到資料庫的php代碼 複製代碼 代碼如下:If($Picture != "none") { $PSize = filesize($Picture); $mysqlPicture = addslashes(fread(fopen($Picture, "r"), $PSize)); mysql_connect($host,$username,$password) or die("Unable to connect to SQL server");