Time of Update: 2016-07-13
分享一個非常實用,本人一直在用的利用php彈出警告的函數,整理到自己的程式碼程式庫中去在遇到錯誤的地方可用到此函數,擴充性強,完整代碼如下 複製代碼 代碼如下: //********彈出alert框並跳轉到指定頁面******// function alert($message,$url='',$isAlert=true,$title='提示'){ echo '',$title,''; echo ''; echo ''; exit(); } http://www.bkjia.com/PHPjc/
Time of Update: 2016-07-13
複製代碼 代碼如下:function getAgeByID($id){ //過了這年的生日才算多了1周歲 if(empty($id)) return ''; $date=strtotime(substr($id,6,8));//獲得出生年月日的時間戳記 $today=strtotime('today');//獲得今日的時間戳記
Time of Update: 2016-07-13
主介面: 可以擷取商家產品,擷取新聞資訊等。如果你感興趣,可以關注一下這個平台。掃描二維碼,或在添加好友,尋找公眾號,搜尋“園藝街”關注。 謝謝!歡迎就這方面問題交流。http://www.bkjia.com/PHPjc/714715.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/714715.htmlTechArticle主介面: 可以擷取商家產品,擷取新聞資訊等。如果你感興趣,可以關注一下這個平台。
Time of Update: 2016-07-13
在寫註冊系統時,如果要檢查使用者名稱是否存在,php可以這樣寫: 複製代碼 代碼如下: $username=$_REQUEST['username']; $password=$_REQUEST['password']; echo "excute the insertUserInfo"; $con=mysqli_connect("localhost","root","","my_db"); $sql="SELECT * FROM user WHERE username='$username'";
Time of Update: 2016-07-13
使用圖形顯示Ip,檔案 sunip.php 複製代碼 代碼如下:header("Content-type: image/gif"); $im = imagecreate(130,15); $background_color = ImageColorAllocate ($im, 255, 255, 255); unset($ip); if($_SERVER['HTTP_CLIENT_IP']){ $ip=$_SERVER['HTTP_CLIENT_IP']; } else if($_SERVER[
Time of Update: 2016-07-13
複製代碼 代碼如下:function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:''; function CheckSubstrs($substrs,$text){
Time of Update: 2016-07-13
複製代碼 代碼如下:header("content-type:text/html;charset=utf-8");$weather = file_get_contents("http://www.weather.com.cn/data/sk/101280601.html");echo $weather;?> 複製代碼
Time of Update: 2016-07-13
calendar.class.php 複製代碼 代碼如下: class Calendar { private $year; //當前的年 private $month; //當前的月 private $start_weekday; //當月的第一天對應的是周幾 private $days; //當前月一共多少天 function __construct(){ $this->year=isset($_GET["year"]) ? $_GET["year"] : date("Y");
Time of Update: 2016-07-13
什麼是HTTP Referer簡言之,HTTP Referer是header的一部分,當瀏覽器向web伺服器發送請求的時候,一般會帶上Referer,告訴伺服器我是從哪個頁面連結過來的,伺服器籍此可以獲得一些資訊用於處理。比如從我首頁上連結到一個朋友那裡,他的伺服器就能夠從HTTP
Time of Update: 2016-07-13
複製代碼 代碼如下:ini_set('display_errors', 'on'); $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR; $PNG_WEB_DIR = 'temp/'; include "qrlib.php"; // QRcode lib $data = 'http://www.jb51.net'; // data $ecc = 'H'; //
Time of Update: 2016-07-13
回答:當有人想要實現並發功能時,他們通常會想到用fork或者spawn threads,但是當他們發現php不支援多線程的時候,大概會轉換思路去用一些不夠好的語言,比如perl。其實的是大多數情況下,你大可不必使用fork或者線程,並且你會得到比用fork或thread更好的效能。假設你要建立一個服務來檢查正在啟動並執行n台伺服器,以確定他們還在正常運轉。你可能會寫下面這樣的代碼:複製代碼 代碼如下:$hosts = array("host1.sample.com",
Time of Update: 2016-07-13
複製代碼 代碼如下:function getIPLoc_sina($queryIP){ $url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$queryIP; $ch = curl_init($url); curl_setopt($ch,CURLOPT_ENCODING ,'utf8'); curl_setopt($ch, CURLOPT_TIMEOUT, 5);
Time of Update: 2016-07-13
密碼編譯演算法如下:複製代碼 代碼如下:function encrypt($data, $key){ $key = md5($key); $x = 0; $len = strlen($data); $l = strlen($key); for ($i = 0; $i { if ($x == $l) { $x = 0; } $char .= $key{$x}; $x++;
Time of Update: 2016-07-13
複製代碼 代碼如下:function getIPLoc_QQ($queryIP){ $url = 'http://ip.qq.com/cgi-bin/searchip?searchip1='.$queryIP; $ch = curl_init($url); curl_setopt($ch,CURLOPT_ENCODING ,'gb2312'); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_
Time of Update: 2016-07-13
1.執行複製代碼 代碼如下:yum install php-mbstring2. 修改php.ini (這一步非常重要, 部分lxadmin版本無法自動修改)複製代碼 代碼如下:echo ‘extension=mbstring.so' >>/etc/php.ini #更具php安裝目錄而定3. 重啟web service如果是apache: service httpd restart方法二:php 5.36安裝目錄:/usr/local/php 複製代碼 代碼如下:#cd
Time of Update: 2016-07-13
這篇文章主要介紹了使用openssl實現rsa非對稱式加密演算法的樣本,大家參考使用吧 代碼如下:_keyPath = $path; } /** * create the key pair,save the key to $this->_keyPath */ public function createKey() { $r = openssl_pkey_new();
Time of Update: 2016-07-13
很多情況下我們不知道是php錯誤,還是mysql使用者名稱密碼不對導致cms運行錯誤,可以先用下面的代碼測試一下就可以了方法很簡單: 將下面的代碼儲存為test.php,放到web目錄裡面執行即可。 代碼如下: 其中mysql_connect( )函數的參數依次為:mysql伺服器名或IP、mysql使用者名稱,mysql使用者密碼。
Time of Update: 2016-07-13
需要提取的內容如下:複製代碼
Time of Update: 2016-07-13
複製代碼 代碼如下: [root@abc lnmp]# service php-fpm start Starting php-fpm eAccelerator: Could not allocate 67108864 bytes, the maximum size the kernel allows is 33554432 bytes. Lower the amount of memory request or increase the limit in
Time of Update: 2016-07-13
複製代碼 代碼如下:/** * 抽獎 * @param int $total */function getReward($total=1000){ $win1 = floor((0.12*$total)/100); $win2 = floor((3*$total)/100); $win3 = floor((12*$total)/100); $other = $total-$win1-$win2-$win3; $return = array(); for ($i=0;$i { $return[]