today's offers - xanax use in pregnancy xanax xr be abused soma internet pharmacies fedex soma without priscription fed ex phentermine parkinson drugs phentermine baclofen tramadol together ordering tramadol cod viagra find search 76k cialis pages cialis buy on line viagra for sale without a prescription buy onlinecom phentermine viagra ambien and klonopin drug interaction buy ambien overnight cheap online pharmacies valium saturday delivery valium online with no prescription or membership fioricet overnight no rx cheap fioricet without a prescription order meridia cod fedex meridia cheap fed ex delivery xanax bradycardia what does xanax look like american soma how to buy soma online without prescriptin phentermine overnight echeck c o d 375 mg phentermine rss feed cheap no prescription tramadol stop the tramadol generic prices online cialis generic cialis fedex chinese herbal viagra taking partial pill of viagra ambien and pregnancy smoking ambien cod online valium buy cheap valium without prescription no prescription fioricet with fedex fioricet without prescription in Brasilia order meridia meridia information

Posts Tagged php

system() & exec()

system()
The system() call also tries to automatically flush the web server’s output buffer after each line of output if PHP is running as a server module.
exec()
則不會flush

遇到的問題是
我的php 透過perl 去執行一些功能
然後perl 回傳 success or false 字串 在standard output 上
php再去get 這個字串
success 則print success
給 ajax 來判斷

結果 在前端的ajax 一直印出 successsuccess
的字眼
想說怎麼會印兩次….
看了一下手冊才發現這個

之前就想說 php 幹麻沒事有兩個 執行CLI 的東西……
仔細看了一下手冊才知道
筆記一下..

No Comments

php preg_replace bug ??

這個問題在在Zend Framework 中
Zend/Db/Statement.php
裡面
[cc lang="php" tab_size="2" lines="40"]
protected function _stripQuoted($sql)
{
// get the character for delimited id quotes,
// this is usually ” but in MySQL is `
$d = $this->_adapter->quoteIdentifier(‘a’);
$d = $d[0];

// get the value used as an escaped delimited id quote,
// e.g. \” or “” or \`
$de = $this->_adapter->quoteIdentifier($d);
$de = substr($de, 1, 2);
$de = str_replace(‘\\’, ‘\\\\’, $de);

// get the character for value quoting
// this should be ‘
$q = $this->_adapter->quote(‘a’);
$q = $q[0];

// get the value used as an escaped quote,
// e.g. \’ or ”
$qe = $this->_adapter->quote($q);
$qe = substr($qe, 1, 2);
$qe = str_replace(‘\\’, ‘\\\\’, $qe);

// get a version of the SQL statement with all quoted
// values and delimited identifiers stripped out
// remove “foo\”bar”
$sql = preg_replace(“/$q($qe|\\\\{2}|[^$q])*$q/”, ”, $sql);
// remove ‘foo\’bar’
if (!empty($q)) {
$sql = preg_replace(“/$q($qe|[^$q])*$q/”, ”, $sql);
}

return $sql;
}

[/cc]
發現的
我是要執行一段db->query($sql)
sql 是 insert into xxx
有把sql 單純的print 出來到mysql 中執行是可以成功執行的
trace 到最後發現會卡在preg_replace這邊
而看httpd error , access log 都沒有訊息
看message log 就會出現
Nov 12 13:22:33 mail kernel: pid 50728 (httpd), uid 80: exited on signal 4
所以判斷應該是
php 的bug

我的解法是不用preg_replace 換成
ereg_replace, mb_ereg_replace
都可以.

No Comments

在vim 下debug php (use xdebug)

1.VIM 的部份
在你的vim 下
:version
看看有沒有+python 和+sign
沒的話….
把vim 重裝…
#make install WITH_PYTHON
這樣應該就會有了…

2.安裝Script
去這個地方抓

http://www.vim.org/scripts/script.php?script_id=1929

放到/usr/local/share/vim/vim71/plugin/底下…

3.安裝xdebug
#cd /usr/ports/devel/php-xdebug
#make install
#vim /usr/local/etc/php.ini

[Zend]
zend_extension = /full/path/to/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = localhost

加入上面這幾行..
看一下phpinfo 有沒有出現xdebug

4.
然後開browser run你的url 後面的?XDEBUG_SESSION_START=1 這是重點..
例如 http://example.com/index.php?XDEBUG_SESSION_START=1

5.
#vim xxx.php
然後按F5
下面就會出現
waiting for a new connection on port 9000 for 5 seconds
然後這時後你有五秒去開你的url
例如

http://example.com/xxx.php

再回去看你的vim 就開始在debug ……….

到這邊就差不多了…

PS
1.
如果phpinfo 告訴你
XDEBUG NOT LOADED AS ZEND EXTENSION
那這樣是沒辦法…..去debug 的雖然可以F5 去跑..
不過step over 之類的都不能用…

2.
因為…我在vim 下按 F2 F3 會轉換大小寫…和他的function key 有衝到…
去看debugger.vim 下..
他有這段
map <Leader>dr :python debugger_resize()<cr>
map <Leader>di :python debugger_command(’step_into’)<cr>
map <Leader>do :python debugger_command(’step_over’)<cr>
map <Leader>dt :python debugger_command(’step_out’)<cr>

<Leader> = \
所以我step over 是用 \do
以此類推..

希望對有用vim 的同好有幫助 。
^^
我終於可以脫離”print 大法”了…..

Ref.
http://2bits.com/articles/using-vim-and-xdebug-dbgp-for-debugging-drupal-or-any-php-application.html
How do debug php with vim and xdebug on linux

, ,

3 Comments

PHP Universal Feed Generator 中文問題..

之前忘了在那看到這個 PHP Universal Feed Generator 感覺還滿好用的…
結果就在這幾天要用的時後…
發現他中文在轉碼的時後有問題…
trace 一下他的code 發現是298 行的
htmlentities($tagContent);這個的問題
把他換成
htmlentities($tagContent, ENT_COMPAT, ‘utf-8′);
應該就可以了
另外看了一下他在header 的部份沒有宣告是UTF8
所以我也修改了一下….
在84 行
header(“Content-type: text/xml”);
改一下
header(“Content-type: text/xml; charset=UTF-8″);

基本上這樣應該就可以了…

1 Comment

php 找出日期的差距天數

記得先compile calendar 這個php extension 才會有
gregoriantojd 這個function..

http://roshanbh.com.np/2008/03/finding-days-difference-php.html

PS
之前都是自已硬幹…..
用mktime date轉來轉去才算出來的…

No Comments

unexpected end-of-file (perhaps the fastcgi process died):

看起來似乎是php5.2.5的bug………………

http://bugs.php.net/bug.php?id=43295

以前都覺得怎麼會有人踩到地雷
想說怎麼可以這麼倒霉
沒想到我也會踩到….

目前就先downgrade
看起來就沒這個情況了 。

No Comments