Time of Update: 2017-01-13
密碼安全原理 0:低,1:中,2:高三個層級,千萬不要用百分比具體就不說,強度我們從最簡單的純數字到數字英文及最進階的數字英文及特殊字元 代碼如下/** * 擷取密碼安全等級 * @param string $password 密碼 * @return int 0:低,1:中,2:高*/function password_level($password){&
Time of Update: 2017-01-13
從5.2版本開始,PHP原生提供json_encode()和json_decode()函數,前者用於編碼,後者用於解碼。一、json_encode()string json_encode ( mixed $value [, int $options = 0 ] ):該函數主要用來將數組和對象,轉換為json格式。$value為要轉換的資料,除了resource 類型之外,可以為任何資料類型。該函數只能接受 UTF-8 編碼的資料,否則會得到Null 字元或者null。$arr = array (
Time of Update: 2017-01-13
周末閑來無事看到了原型模式,其中談到了淺複製和深複製,想到PHP中的對應賦值、複製以及複製是淺複製還是深複製。先來看看賦值,例如有一個簡曆類,有身高和體重兩個屬性:class Resume { public $height; public $weight; public $workExperienc
Time of Update: 2017-01-13
magic_quotes_gpc的設定值將會影響通過Get/Post/Cookies獲得的資料這兩天接入百度SDK處理支付回調時碰到了簽名通不過的情況,簽名規則很簡單,md5(transdata + appkey) 和
Time of Update: 2017-01-13
首先解決file_get_contents的逾時問題,在逾時返回錯誤後就象js中的settimeout那樣進行一次嘗試,錯誤超過3次或者5次後就確認為無法連線伺服器而徹底放棄。這?就簡單介紹兩種解決方案:一、增加逾時的時間限制注意:set_time_limit只是設定你的PHP程式的逾時時間,而不是file_get_contents函數讀取URL的逾時時間。我一開始以為set_time_limit也能影響到file_get_contents,後來經測試是無效的。真正的修改file_get_con
Time of Update: 2017-01-13
本文承接上面兩篇,本篇中的樣本要調用到前兩篇中的函數,做一個簡單的URL採集。一般php採集網路資料會用file_get_contents、file和cURL。不過據說cURL會比file_get_contents、file更快更專業,更適合採集。今天就試試用cURL來擷取網頁上的所有連結。樣本如下:<?php/* * 使用curl 採集111cn.net下的所有連結。 */include_once('function.php');$ch =
Time of Update: 2017-01-13
php儲存檔案,還可以根據檔案路徑自動連續建立目錄,代碼如下(註:PHP要版本5以上):<?php /** * 儲存檔案 * * @param string $fileName 檔案名稱(含相對路徑) * @param string $text 檔案內容 * @return boolean */ function saveFile($fileName, $text) { if
Time of Update: 2017-01-13
在輸出資料到螢幕上顯示的時候,如果資料較大,位元較多,看上去會比較費勁,有一種比較直觀的方法是使用千分位,也就是每三位元字顯示一個逗號,這樣可以快速的知道數的大小,不用一位位的去慢慢數了。令人高興的是,php中有專門的函數可以完成這個任務,可以在輸出資料的時候自動加上千分位。string number_format ( float number [, int decimals [, string dec_point, string thousands_sep]]
Time of Update: 2017-01-13
if ('source' == $_get['act']) { //查看原始碼show_source($_server["script_filename"]);exit;} //end ifset_time_limit(0);for ($i = 0; $i < 5000; $i++) {$users[] = 'tom_' . $
Time of Update: 2017-01-13
代碼如下複製代碼 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-
Time of Update: 2017-01-13
/*下面這幾款php產生flash檔案代碼,是從簡單的產生swf檔案到產生 flash動畫檔案等,每個執行個體都是經典的。*///首先開啟php擴充php_ming$f = new swffont( '_sans' );$t = new swftextfield();$t->setfont( $f );$t->setcolor( 0, 0, 0 );$t->setheight( 400 );$t->addstring( 'hello world' );$m = new
Time of Update: 2017-01-13
代碼如下複製代碼 session_start(); include("mysql教程.class.php"); $db=new mysql('localhost', 'root', '', 'flx', 'conn', 'gbk'); // 為方便測試,這裡只是簡單定義了一個特定的使用者,在實際操作中,使用者資訊從資料庫教程中得出; define('user','admin');
Time of Update: 2017-01-13
這款教程會用到php檔案view.phpconfig.phpfuns.phpindex.php功能:-----------------------1.為檔案夾裡的圖片產生指定大小縮圖2.列出子檔案夾, 可以指定生生某檔案夾產生3.為方便不同大小的縮圖產生,圖片儲存到新的目錄,而目錄結構不變實現:-----------------------1.圖片原檔案夾 $image2.處理後儲存在
Time of Update: 2017-01-13
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net1999/xhtml"><head><meta
Time of Update: 2017-01-13
些購物車會用到php檔案 main.php 顯示商品 additem.php把商品加入購物車 cearcart.php刪除購物車中的商品 shoppingcart.php 操作類 使用者的資料庫教程有 代碼如下複製代碼 inventory create table inventory ( product tinytext not null, &
Time of Update: 2017-01-13
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/1999/xhtml"><head><meta
Time of Update: 2017-01-13
代碼如下複製代碼 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/1999/xhtml"><head><meta
Time of Update: 2017-01-13
代碼如下複製代碼 $info=csvtoarray::open('teste.csv');//echo '<pre>';//print_r($info);//echo '</pre>';foreach ($info as $c) { echo '學號:'.$c[0]; echo '姓名:'.$c[1]; echo '年齡:'.$c[2]; echo '身高:
Time of Update: 2017-01-13
在Gitlab上的代碼倉庫,如果是通過ssh方式拉取代碼,需要在兩台機器之間建立ssh信任,而通過WEB系統(基於PHP)操作git,也要建立PHP進程使用者和Gitlab機器的ssh信任。簡而言之,就是兩台機器使用者之間建立信任很簡單,但是PHP進程使用者也要建立ssh信任,這裡面遇到一些問題。這涉及到Linux使用者的概念和許可權問題,其實還是對Linux不夠瞭解。兩台機器建立ssh-key信任很簡單,需要兩步操作就可以了。1.產生ssh-keyssh-keygen -t rsa -C
Time of Update: 2017-01-13
clickdemo.html:此檔案包含與連結的html和ajax代碼。clicktrack.php:php返回操作資訊<body><a href="http://www.111cn.net" onclick="dowork(this);"