php用於判斷檔案是否存在、是否可讀、目錄是否存在的代碼

$file = 'jbxue.com.php';if (is_readable($file) == false) {die('檔案不存在或者無法讀取');} else {echo '存在';}?>複製代碼is_readable() 函數判斷指定檔案名稱是否可讀.指定的檔案或目錄存在並且可讀,則返回 TRUE例2: $filename = 'jbxue.com.php';if (file_exists($filename)) {echo "The file $filename exists";}

php使用ftp函數實現簡單上傳功能

/** ftp上傳檔案 link:bbs.it-home.org date:2013/2/25*/$ftp_server = "192.168.8.8";$ftp_user = "test123";$ftp_pass = "yourpassword";// set up a connection or die$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");$login_result

php文本文章分頁程式碼範例

/** * ********************************************************** * Read Me * 文章分頁 * * 分頁方式,可以按字數分頁,按換行分頁,按特殊標記分頁等 * 其實實現思路是一樣的,只是將其按一定規律放入一個數組 * 然後根據 url 傳入的參數取得某個片段即可 * * * filename: page.php * charset: UTF-8 * create date: 2012-5-16 * *************

理解php5中的this,self,parent關鍵字用法

class UserName{//定義屬性private $name;//定義建構函式function __construct( $name ){$this->name = $name; //這裡已經使用了this指標}//解構函式function __destruct(){}//列印使用者名稱成員函數function printName(){print( $this->name ); //又使用了this指標}}//執行個體化對象$nameObject = new UserName(

php資料備份:單表備份 整表備份 匯入資料庫

class Db { var $conn; function Db($host="localhost",$user="root",$pass="root",$db="test") { if(!$this->conn=mysql_connect($host,$user,$pass)) die("can't connect to mysql sever");

Drupal-7.12 建立節點類型

drupal 網站開發 function examplenode_install() { //Updates the database cache of node types node_types_rebuild(); $types = node_type_get_types(); // add the body field to the node type

google,bing,youdao翻譯的實現

Google翻譯的實現是通過:抓取網頁翻譯的結果的。 Bing翻譯是調用它的API,糾正官方範例程式碼的錯誤。 Youdao翻譯是調用它的API的。 原文:http://blog.satikey.com/?p=183 另外有一些介面可以用,返回的是json資料格式 比如 通過youdao: http://api.satikey.com/?via=youdao&text=翻譯樣本 通過google:

php 建立短地址 (var_export)的方法

複製代碼處理頁面 show.php: include 'functions.php'; include 'shorturls.php'; $entry = $_POST['submit']; $url = $_POST['url']; $output = ''; if($entry == 'Shorten Url' AND $url) {

php擷取用戶端瀏覽器與作業系統資訊的方法

//顯示訪問使用者的瀏覽器資訊echo 'Browser: ' . determinebrowser($Agent) . '';//顯示訪問使用者的作業系統平台echo 'Platform: ' . determineplatform($Agent). '';//正值運算式比對解析$_SERVER['HTTP_USER_AGENT']中的字串 擷取訪問使用者的瀏覽器的資訊function determinebrowser ($Agent) {$browseragent="";

zf中Invalid command 'RewriteEngine'錯誤的解決辦法

zend framework tutorial,運行例子,報如下的錯誤:The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.zend framework tutorial,運行例子,報如下的錯誤:The server encountered

php普通表單多檔案上傳的代碼

/** class: 檔案上傳類* author: ZMM* date: 2011.1.20* email: 304924248@qq.com* link: http://bbs.it-home.org*/class Upload {public $up_ext=array(), $up_max=5210, $up_dir;private $up_name, $up_rename=true, $up_num=0, $up_files=array(),

php產生指定長度的密碼的代碼(圖文)

寫了一個產生指定長度密碼的函數,有需要的朋友,可以參考下。參數$strength用於確定選擇產生什麼格式的密碼,包括小寫字母組成的字串,大寫字母組成的字串,或純數字...用php寫了一個產生指定長度密碼的函數。參數$strength用於確定選擇產生什麼格式的密碼,包括小寫字母組成的字串,大寫字母組成的字串,或純數字,或以上三種與特殊字元的組合。 調用樣本: 

php 摘要產生函數(自訂,無亂碼)

/** php摘要產生函數 link:http://bbs.it-home.org 2013-3-7*/function cutstr($string, $length,$charset,$dot) {//字元,截取長度,字元集,結尾符if(strlen($string) return $string;}$pre = chr(1);$end = chr(1);//保護特殊字元串$string = str_replace(array('&', '"', ''), array($pre.'&'.

php中文字串截取(mb_substr)執行個體

$str='指令碼學堂:http://bbs.it-home.org';echo mb_substr($str,0,4,'utf-8');//截取頭5個字,假定此代碼所在php檔案的編碼為utf-8?> 複製代碼 輸出:程式員之家2、擷取中文長度:mb_strlen()mb_strlen( $str, $encoding )$str,要計算長度的字串$encoding,網頁編碼,如utf-8,GB2312,GBK例2:

php解析XML文件屬性並編輯的代碼

//讀取xml $dom=new DOMDocument('1.0');$dom->load('data.xml');$em=$dom->getElementsByTagName('videos');//最外層節點$em=$em->item(0);$items=$em->getElementsByTagName('video');//節點//如果不用讀取直接添加的話把下面這一段去掉即可foreach($items as $a){foreach($a->attributes as

php寫的一個登入驗證類

final class UserLogin { public function __construct() { } public static function getUserInfo() { if (isset($_COOKIE["user_id"])&&$_COOKIE["user_id"]&&(trim($_COOKIE["user_id"])!="")) { if

php快速建立數組的方法(函數range()的應用)

$numbers=range(1,9); //用range直接建立1~9共9個數字組成的數組,以“1”開始“9”結束。 echo $numbers[1]; //輸出建立的第二個數組值:2; echo $numbers[0];則輸入第一個值:0。 ?>複製代碼當然,使用range(9,1)則建立了9到1的數字數組。同時,PHP函數range()還可以建立從a到z 的字元數組: $numbers=range(a,z); foreach

php 產生 匯出word(可包含圖片)的代碼

/***********************************************************************Class: Mht File MakerVersion: 1.2 betaLink:bbs.it-home.orgAuthor: Wudi Description: The class can make .mht file.*****************************************************************

php擷取副檔名的幾種方法

php擷取副檔名的幾種方法,有需要的朋友可以參考下。方法1:function get_extension($file){substr(strrchr($file, '.'), 1);}方法2:function get_extension($file){return substr($file, strrpos($file, '.')+1);}方法3:function get_extension($file){return end(explode('.',

php 數組排序(升序、降序及相關問題)

$a = array(4,"37",3,100,0,-5); sort($a); for ($i=0; $iecho $a[$i]." "; } echo ""; sort($a,SORT_STRING); for ($i=0; $iecho $a[$i]." "; } echo ""; ?>複製代碼輸出結果:-5 0 3 4 37 100 -5 0 100 3 37 4降序排序:rsort(array, [sort type]) 參數用法與sort函數相同。關聯陣列排序:

總頁數: 5203 1 .... 1411 1412 1413 1414 1415 .... 5203 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.