Time of Update: 2017-01-13
這篇文章主要介紹了php計算年齡精準到年月日的方法,涉及php操作日期與字串的相關技巧,非常簡單實用,需要的朋友可以參考下本文執行個體講述了php計算年齡精準到年月日的方法。分享給大家供大家參考。具體如下: $ni) { $not_birth = 1; $tmp = array($byear, $bmonth,
Time of Update: 2017-01-13
方法一<?php 代碼如下複製代碼 echo strip_tags("hello <b>world!</b>"); strip_tags --- 去除字串中的html和php標籤文法 : string strip_tags (string str [, string allowable_tags])說明 :此函式試著從給予的字串中去除所有html和php標籤,如果是不完整或是假的標籤時則會有錯誤,它和fgetss(
Time of Update: 2017-01-13
其實對於PHP程式員來說,基本上每個指令碼都涉及到了輸出緩衝,只是在大多數情況下,我們都不需要對輸出緩衝變更。而今天就來用執行個體對PHP輸出緩衝控制函數“Output Control”做一個詳細的解析。下面這個例子簡單介紹了輸出緩衝在一般指令碼中存在的方式:我們在執行如下指令碼時: 代碼如下複製代碼 <?php/*例1*/echo 'oschina.net';echo '紅薯';echo '蟲蟲';?>
Time of Update: 2017-01-13
將一個簡訊介面代碼從apache遷移到nginx+php-fpm後,發現無法發出簡訊了,查看php日誌,[25-Sep-2014 20:15:21] WARNING: [pool www] child 9617 said into stderr: “NOTICE: PHP message: PHP Fatal error: Call to undefined function mb_convert_encoding() in /data/htdocs/xx.php on
Time of Update: 2017-01-13
還有伺服器和mysql教程也要加強一些安全防範。對於linux伺服器的安全設定:加密口令,使用“/usr/sbin/authconfig”工具開啟密碼的shadow功能,對password進行加密。禁止訪問重要檔案,進入linux命令介面,在提示符下輸入:#chmod 600 /etc/inetd.conf //改變檔案屬性為600#chattr +i
Time of Update: 2017-01-13
自訂的一個函數 代碼如下複製代碼 function StripHTML($string){ $pattern=array ("'<script[^>]*?>.*?</script>'si", "'<style[^>]*?>.*?</style>'si", "'<[/!]*?[^<>]*?>'si",
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
Time of Update: 2017-01-13
註:如果在用mb_strlen出現fatal error: call to undefined function mb_strlen,這種問題你要可以用php教程info()看一下有沒有裝載mbstring,如果沒有,嘗試將php_mbstring.dll複製到%windows%目錄下。檔案編碼 utf-8$var = '中文字元abc';mb_strlen($var, 'utf-8'); // 輸出7 中文英文都佔一個位元組mb_strlen($var); // 輸出15 中文佔3個位元組
Time of Update: 2017-01-13
程式中添加時間的初始化語句:“date_default_timezone_set("asia/shanghai");定義和用法the date_default_timezone_set() function sets the default timezone used by all date/time functions.date_default_timezone_set()函數的作用是:設定用於一個指令碼中所有日期時間函數的預設時區。syntax文法
Time of Update: 2017-01-13
php教程 require/include順序詳解在大型的web項目中, include_path是一個模組化設計的根本中的根本(當然,現在也有很多基於autoload的設計, 這個不影響本文的探討), 但是正是因為include_path, 經常會讓我們遇到一些因為沒有找到正確的檔案而導致的看似”詭異”的問題.也就有了如下的疑問:include_path是怎麼起作用的?如果有多個include_path順序是怎麼樣的?什麼情況下include_path不起作用?今天,
Time of Update: 2017-01-13
Nginx 配置虛擬機器主機網域名稱 mingzi.111cn.net,當瀏覽者訪問主站時,通過代理去訪問 server1.mingzi.111cn.net 網站。從而達到一種負載平衡的作用。以下是Nginx負載平衡,反向 Proxy的配置: 代碼如下複製代碼 server { server_name mingzi.111cn.net; listen 80;
Time of Update: 2016-08-02
標籤:zabbix1、安裝phpyum install -y php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhashvim /etc/php.inimax_input_time 
Time of Update: 2016-07-22
標籤:前兩天學習到的知識,挺有用的,因此這裡做個分享function AutoCreateSql($tab,$dataarr,$mode=‘insert‘,$where=‘ 1 and 1 limit 1‘){ //形如 insert into test(t1,t2) values(‘v1‘,‘v2‘) update test set t1=‘v1‘,t2=‘v2‘ where id = 1 //delete 語句的參數 應該 是 表 where 條件
Time of Update: 2016-06-14
標籤: 在動態網面設計中很多都要涉及到對資料庫的操作,但是有時跟據需要而改用其它後台資料庫,就需要大量修改程式。這是一件枯燥、費時而且容易出錯的功作。其實我們可以用PHP中的類來實現對資料庫操作的封裝,從而使寫出的程式在很小的改動下就可以完成後台資料庫的更改。<?class dbInterface{ var $dbID=1; //用於確定當前操作的資料庫,當dbID為1代表MySql,當為 2代表 SQL Server,為3時為ODBC或其它。var
Time of Update: 2015-07-10
標籤:使用pdo串連資料庫在使用thinkphp架構下在自己的頁面單獨使用PDO需要use PDO;然後才能使用try { //$dbh = new PDO ($dsn,$username,$pwd); $dbh = new PDO(‘sqlsrv:Server=127.0.0.1,1433;Database=SQLtest‘,"sa", "zhengfeng79"); foreach( $dbh -> query ( ‘SELECT * from [user]‘ )
Time of Update: 2015-06-21
標籤:一.匯入 匯入需要使用能讀取Excel的組件,網上也有比較好的組件,這裡分享我使用的:下載 提取碼:vxyn。(注意兩個檔案有參考關聯性)<?php//傳入要匯入的Excel的檔案名稱function import_to_DB($filename) { require_once‘reader.php‘; $data = new Spreadsheet_Excel_Reader(); //建立讀取Excel的對象
Time of Update: 2015-06-04
標籤:1. connection $mysqli = new mysqli($host,$user,$passwd,$db,$port); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; }2. select query$sql="SELECT
Time of Update: 2015-07-23
標籤:Php多線程的使用,首先需要PHP5.3以上版本,並安裝pthreads PHP擴充,可以使PHP真正的支援多線程,擴充如何安裝請自行百度PHP擴充下載:https://github.com/krakjoe/pthreadsPHP手冊文檔:http://php.net/manual/zh/book.pthreads.php在安裝好擴充之後,就可以運用多線程了,下面貼個通過搜尋結果抓取百度網盤內容的代碼:<?phpinclude ‘include/CurlLoad.class.php‘
Time of Update: 2017-01-11
標籤:service localhost 錯誤 alt c運行庫 doc htm add 計算 ?資源下載(apache24,php7,phpStorm9)?修改apache24設定檔?安裝和啟
Time of Update: 2015-07-19
如何用supervisor守護php-fpm主進程以實現php-fpm的自動重啟,supervisorphp-fpm 最近有同事有個針對php-fpm進程的監護需求,也即:如果php-fpm的master進程意外退出(可能是crash,也可能是被誤kill),那麼希望master進程能被自動拉起,以免中斷服務。我們知道,supervisor是一個非常強大的進程監控(monitor & control)工具,它理論上可以實現php-fpm