Home >Backend Development >PHP Tutorial >Remember an error debugging, about php command line [php cli] php cli mode php cli server php cli multi-line

Remember an error debugging, about php command line [php cli] php cli mode php cli server php cli multi-line

WBOY
WBOYOriginal
2016-07-29 08:54:581185browse

I have encountered a requirement in the past few days. This requirement is written in a php file. This file is best executed on the command line.

But something went wrong.

When I execute the php file in the browser, ok, everything is fine.

But,

When I execute it in the command line, an error occurs!

The error message is:

<code>PHP Fatal error:  Uncaught Exception: could <span>not</span> find driver <span>in</span> /<span>var</span>/www/html/huxintong_admin/include/lib/DataBase.<span>class</span>.php:<span>149</span>
Stack trace:
<span>#0</span> /<span>var</span>/www/html/huxintong_admin/include/<span>class</span>/Base.<span>class</span>.php(<span>9</span>): DataBase->__construct(<span>Array</span>)
<span>#1</span> /<span>var</span>/www/html/huxintong_admin/include/<span>class</span>/System.<span>class</span>.php(<span>22</span>): Base::__instance()
<span>#2</span> /<span>var</span>/www/html/huxintong_admin/include/crontab/remind/qb_sms_remind_queue.php(<span>13</span>): System::get(<span>'timezone'</span>)
<span>#3</span><span>{main}</span>
  thrown <span>in</span> /<span>var</span>/www/html/huxintong_admin/include/lib/DataBase.<span>class</span>.php <span>on</span> line <span>149</span></code>

ok, it’s obvious! PHP does not have a pdo driver under cli, okay.

So, I located /etc/php5/cli and made a series of configurations below to ensure that the pdo driver was added, but, but, it still didn’t work!

Collapse!

But there is no other way, reinstalling is too troublesome.

Don’t explode in silence, just explode in silence. This time, I exploded.

Searching on Du Niang, no answers to related questions were found. Programmers, let’s use Google!

Google this question and search it in English.

I checked the stackoverflow webpage, and there are many people who have encountered the same problem as me.

So, I checked other people’s suggestions:
Use php -i to view the detailed information of php under cli
Use php -m to view which modules php is loaded under cli
Use php –ini to view which ini files are loaded by php

It doesn’t matter if you type php –ini, okay. The configuration file under /etc/php/7.0 is loaded.

God, I don’t know when php7.0 was installed. I said why can’t it work? . .

It turns out that I have been changing the configuration files under php5.0, and I have been using the configuration files under php7.0.

Okay, let’s not work on php7.0 for now.

From
php test.php
to
php5 test.php
Solve the problem

Appendix: stackoverflow this question

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the debugging of an error. Regarding the php command line [php cli], it includes the contents of php and cli. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn