問題
這個問題是因為在 ubuntu 不知道哪一版開始,預設會把 php 刪除 session 的動作關掉
然後系統會自行使用 /usr/lib/php/sessionclear 的命令來清除 session
但預設刪除的是 sess_* 的檔案
但 CodeIgniter 3 產生的 session 檔案為 ci_session* 的檔案
所以 session 會一直留在目錄裡面,直到 目錄的 index 爆掉為止
筆記
session 預設目錄: /var/lib/php/sessions
session 刪除檔案的命令: /usr/lib/php/sessionclear
PHP 原生的 session 檔名: SESS_*
Codeigniter 3 建立的 session 檔名: ci_session*
wbkuo 發表在 痞客邦 留言(0) 人氣(153)
第一次看到,快速做個筆記。
function isMatch($url) {
$rx = '~
^([a-z]+) # 註解1
([0-9]+)$ # 註解2
~x';
return preg_match($rx, $url);
}
isMatch("111222333");
// false
isMatch("aaabbccc");
// false
isMatch("a1");
// true
isMatch("abc123");
// true
wbkuo 發表在 痞客邦 留言(0) 人氣(48)
最近經常在寫 Command Line 命令來做資料庫資料的轉換
所以想要弄個進度Bar 來做簡單的時間預估,但沒特殊處理就是一直 echo 很醜
稍微 Google 了一下發現不難處理,以下簡單筆記一下
要做進度 Bar ,就是要把訊息畫在畫面上相同的地方
所以要使用 ANSI escape code: https://en.wikipedia.org/wiki/ANSI_escape_code
然後先決定你要輸出的行數,每次輸出完後,再把游標跳回最一開始的地方就可以了
註:
1. \r = 把游標跳到最開始,所以如果要寫單行的進度Bar 用 \r 就夠了
2. \033[6A = 往上跳六行, \033 代表 ESC 鍵, A 代表往上跳行,6A 就是往上跳六行的意思
程式碼:
wbkuo 發表在 痞客邦 留言(0) 人氣(85)
這個部份我找了好久,官網也沒有寫,但後來自己試出來了,以下是筆記:
新增設定檔
直接在 /config/ 底下隨便複製一個檔案,然後把裡面內容改成自己要的
如:my.php
return [
'test' => 'hello',
];
存取設定檔
放在 /config 底下的所有檔案都會被自動載入,所以直接使用 config() 來存取就可以了
所以上面的設定,就使用 config('my.test') 就取得到 hello 的值了
wbkuo 發表在 痞客邦 留言(0) 人氣(181)
參考文章: http://abandon.ie/notebook/simple-file-uploads-using-jquery-ajax
測試程式碼:
wbkuo 發表在 痞客邦 留言(1) 人氣(5,281)
步驟
1. 安裝 xdebug
# brew install php55-xdebug
2. 編輯 php.ini
# sudo vim php.ini
加上底下這行
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
3. 重開 apache
# sudo apachectl restart
wbkuo 發表在 痞客邦 留言(0) 人氣(263)
錯誤訊息無法顯示時,請照以下步驟檢查
1. 檢查 php.ini
display_errors = On
error_reporting = E_ALL
wbkuo 發表在 痞客邦 留言(0) 人氣(185)
在 CodeIgniter 的 index.php 中有這樣一段程式
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*/
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
switch (ENVIRONMENT)
{
case 'development':
error_reporting(-1);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>='))
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
else
{
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
break;
default:
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
wbkuo 發表在 痞客邦 留言(0) 人氣(1,504)
因為預設的深度是 3 ,所以如果陣列超過 3 層就會被隱藏。
解決方法:
1. 編輯 php.ini
2. 在 xdebug 的區塊加上
xdebug.var_display_max_depth = 100
3. 存檔並重開 apache
參考:http://xdebug.org/docs/display
wbkuo 發表在 痞客邦 留言(0) 人氣(91)
開啟方法:http://www.hostingadvice.com/how-to/enable-php-5-5...
wbkuo 發表在 痞客邦 留言(0) 人氣(47)