php: php.ini
Blogs20102010-12-04
Here I write some notes about setting in php.ini. A little changes will make work easier and lazier.
1. pre-requirements After install PHP env XAMPP, we can find where is the key configure file: php.ini:
- http://localhost/xampp/phpinfo.php
- or command line: $ php —ini
All the following are from php.ini. Change some configures will make work easier and lazier.
2. Use instead of
For print a variable, use instead of seems a better point. Use of this shortcut requires short_open_tag to be on.
; This directive determines whether or not PHP will recognize ; code between tags as PHP source which should be processed as such. ; http://php.net/short-open-tag short_open_tag = on
3. make available ‘tail -f ’ $apache/logs/error.log.
; Besides displaying errors, PHP can also log errors to locations ; such as a server-specific log, STDERR, or a location specified ; by the error_log directive found below. ; http://php.net/log-errors log\errors = On_
- include_path not working?
PEAR library is default included in XAMPP, so from: http://localhost/xampp/pearinfo.php we can get all PEAR info.
Right now suppose we want to code by using MDB2 package, like this:
require_once ‘MDB2.php’; $dsn = ‘mysql://test:test@localhost/test’; $mdb2 =& MDB2::factory($dsn); if (PEAR::isError($mdb2)) { echo ($mdb2->getMessage().’-‘.$mdb2->getUserinfo()); } …
When running, there is always error: Fatal error: Class ‘MDB2’ not found in …
It should be error regarding on path, because we already have PEAR. Check php.ini:
; PHP’s default setting is ”.;/path/to/php/pear” ; http://php.net/include-path include_path = ”.;C:xamppphpPEAR”
It looks correct: PEAR is already in the include_path. However, if we use:
print_r(get_included_files()); echo ”
n”;
or:
set_include_path(get_include_path());
ini_set(‘include_path’, ‘C:xamppphpPEARMDB2.php’);
print_r(get_included_files()); echo ”
n”;
to test, the error is still there, the adding don’t work.
The reason: the ’.;’ at the beginning of include_path setting is not working. They display in phpinfo(), but not active in codes.
So remove it, and change the setting like this:
include_path = “C:xamppxamppphpPEAR”
Right now re-run the codes, it works. This is only applicable in Windows env; if in Linux, it works fine.