這幾天遇到一個需求,這個需求寫在了php檔案裡,這個檔案最好在命令列裡執行。
但是,出問題了。
當我在瀏覽器裡執行php檔案的時候,ok,一切正常。
但是,
當我在命令列裡執行的時候,報錯!
錯誤資訊為:
PHP Fatal error: Uncaught Exception: could not find driver in /var/www/html/huxintong_admin/include/lib/DataBase.class.php:149Stack trace:#0 /var/www/html/huxintong_admin/include/class/Base.class.php(9): DataBase->__construct(Array)#1 /var/www/html/huxintong_admin/include/class/System.class.php(22): Base::__instance()#2 /var/www/html/huxintong_admin/include/crontab/remind/qb_sms_remind_queue.php(13): System::get('timezone')#3{main} thrown in /var/www/html/huxintong_admin/include/lib/DataBase.class.php on line 149
ok,很明顯嘛!php在cli下面沒有pdo驅動,好吧。
於是,我定位到/etc/php5/cli,在這下面進行了一系列的配置,確保添加了pdo的驅動,但是,但是,還是不行!
崩潰了!
但是,沒辦法,重裝太麻煩。
不在沉默中爆發,就在沉默中爆炸,這次,我爆炸了。
在度娘上搜尋,沒有找到相關問題的答案。程式員嘛,還是用Google吧!
google一下這個問題,用英文搜尋。
查看到了stackoverflow的網頁,有不少人碰到和我一樣的問題。
於是,查看了他人的建議:
使用 php -i 查看php在cli下面的詳細資料
使用 php -m查看php 在cli下面載入了哪些模組
使用 php –ini 查看php載入了哪些ini檔案
一敲 php –ini不要緊,好嘛。載入的是/etc/php/7.0下面的設定檔。
老天,什麼時候安裝的php7.0我都不知道,我說怎麼會不行呢。。。
原來,我一直改的都是php5.0下面的設定檔,而一直用的都是php7.0的配置。
好吧,php7.0先不弄了。
從
php test.php
到
php5 test.php
解決問題
附錄:stackoverflow這個問題
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了記一次錯誤調試,關於php命令列[php cli],包括了php,cli方面的內容,希望對PHP教程有興趣的朋友有所協助。