Time of Update: 2016-07-25
#!/usr/bin/php -q$file = "/var/www/".date('H').'_'.date('i').'_'.date('s').'.txt';file_put_contents($file,date('Y-m-d'));?> 複製代碼然後 chmod +x test.php 賦予test.php 可執行檔許可權。3、 命令 crontab -e*/1 * * * * /var/www/test.php每分鐘執行test.php4、/etc/init.d/cron
Time of Update: 2016-07-25
[code]totalpage=$objpage; } //設定當前頁 function setCurrentpage($objpage=1){ $this->currentpage=$objpage; } //設定跨度 function setStride($objStride=1){ $this->stride=$objStride; }//獲得總頁數 function getTotalpage(){ return
Time of Update: 2016-07-25
首先,來看array->xml。$value) {首先,來看array->xml。 function ia2xml($array) { $xml=""; foreach ($array as $key=>$value) { if (is_array($value)) { $xml.="".ia2xml($value).""; } else {
Time of Update: 2016-07-25
/* $cache = new Cache("../cache/",20); // 建構函式,建立緩衝類對象$cache->PutCache(); // 倒出緩衝*/class Cache{private $CacheDir = ’Cache’; /* 緩衝目錄 */private $SetTimeOut = 10; /* 緩衝到期時間 */private $SetExt = ’.cache’; /* 快取檔案尾碼名 */private $CacheFileUrl = ’’; /*
Time of Update: 2016-07-25
張映男28tank男28複製代碼1)DOMDocument讀取xml $doc = new DOMDocument();$doc->load('person.xml'); //讀取xml檔案$humans = $doc->getElementsByTagName_r( "humans" ); //取得humans標籤的對象數組foreach( $humans as $human ){$names = $human->getElementsByTagName_r( "name" );
Time of Update: 2016-07-25
範例程式碼:require('libs/Smarty.class.php');$tpl=new Smarty();$tpl->template_dir='./templates/';$tpl->compile_dir='./templates_c';$tpl->config_di範例程式碼:require('libs/Smarty.class.php');$tpl=new Smarty();$tpl->template_dir='./templates/';$tpl->compile_dir='
Time of Update: 2016-07-25
一、Smarty緩衝的配置$smarty->cache_dir = "/caches/"; //緩衝目錄$smarty->caching = true; //開啟緩衝,為flase的時侯快取無效判定$smarty->cache_lifetime = 60; //緩一、Smarty緩衝的配置$smarty->cache_dir = "/caches/"; //緩衝目錄$smarty->caching = true;
Time of Update: 2016-07-25
$conn= new PDO("mysql:dbname=lamp;host=localhost","root","123456");$sql="select id,username,phone,*** from
Time of Update: 2016-07-25
php小數轉換百分數的函數,感興趣的朋友可以參考下。樣本1:樣本2:如果有小說位元有要求可以用 sprinphp小數轉換百分數的函數,感興趣的朋友可以參考下。樣本1:樣本2:如果有小說位元有要求可以用 sprintf(".2f", $n*100).'%';樣本3:先 四捨五入,後轉換$str=round(5.055, 2); // 5.06$str1=$str."%"; //5.06%#-------------------------sprintf(".2f", $n*100).'%'
Time of Update: 2016-07-25
$s='{"webname":"homehf","url":"www.homehf.com","qq":"744348666"}';$web=json_decode($s); //將字元轉成JSON$arr=array();foreach($web as $k=>$w) $arr[$k]=$w;前三行可以用$web=json_decode($s,true)代替;print_r($arr);?>
Time of Update: 2016-07-25
@session_start();require_once("smarty.php");//載入smarty模板類require_once("adodb/adodb.inc.php");//載入adodb資料庫//串連資料庫$dbhost = 'localhost'; // 資料庫伺服器$dbuser = 'root'; // 資料庫使用者名稱$dbpwd= 'root'; // 資料庫密碼$dbname='hejia'; //資料庫名稱$conn =
Time of Update: 2016-07-25
//第一步 建立解析器 xml_parser_create(編碼);$xml = xml_parser_create('utf-8');//xml_parser_set_option — 為指定 XML 解析進行選項設定//xml_parser_set_option($xml,XML_OPTION_CASE_FOLDING,false);
Time of Update: 2016-07-25
//截取utf8字串function utf8Substr($str, $from, $len) {return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s','$1',$str); }?>複製代碼2、UTF-8、GB2312都支援的漢字截取函數 function
Time of Update: 2016-07-25
$smarty->cache-dir="目錄名"; //建立緩衝目錄名$smarty->caching=true; //開啟緩衝,為false的時候快取無效判定$smarty->cache_lifetime=60; //緩衝時間,單位是秒複製代碼二、Smarty緩衝的使用與清除 $marty->display("cache.tpl",cache_id); //建立帶ID的緩衝$marty->clear_all_cache();
Time of Update: 2016-07-25
php程式員最常犯的11個MySQL錯誤對於大多數web應用來說,資料庫都是一個十分基礎性的部分。如果你在使用PHP,那麼你很可能也在使用MySQL—LAMP系列中舉足輕重的一份子。對於很多新手們來說,使用PHP可以在短短几個小時之內輕鬆地寫出具有特定功能的代碼。但是,構建一個穩定可靠的資料庫卻需要花上一些時日和相關技能。下面列舉了我曾經犯過的最嚴重的11個MySQL相關的錯誤(有些同樣也反映在其他語言/資料庫的使用上)。。。1、使用MyISAM而不是InnoDBMySQL有很多資料庫引擎,但是
Time of Update: 2016-07-25
if (isset($_GET["value"])) { $value = $_GET["value"]; } else { $value = false; } if (is_numeric($value) && ($value >= 15 && $value // run my code } else { // handle the issue }複製代碼這是一個非常基本的例子,我們已經寫更多的行,我想看到??的。首先,因為我們不能確定設定的$
Time of Update: 2016-07-25
header("Cache-Control: public");header("Accept-Ranges: bytes");$file = "a.7z";$filename = "a.7z";$size=filesize($file);$size1=$size-1;//獲得位元組範圍if(isset($_SERVER['HTTP_RANGE'])) { list($name, $range) = explode("=",$_SERVER['HTTP_RANGE']); $length=
Time of Update: 2016-07-25
RewriteEngine onRewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpphp_value include_path "../lib"#------------------------------httpd.confRewriteEngine onRewriteLog "g:\ZendFramework-0.1.2\rewrite.log"RewriteRule !\.(js|ico|gif|jpg|png|css|php)$
Time of Update: 2016-07-25
include_once("smarty/Smarty.class.php");$smarty=new
Time of Update: 2016-07-25
public function fooAction(){ // forward to another action in the current controller and module: $this->_forward('bar', null, null, array('baz' => 'bogus'));}public function barAction(){ // forward to an action in another controller,