PHP意外'(',但没有'('[关闭]

I'm getting many of these errors in my apache logging file:

PHP:  syntax error, unexpected '(' in /etc/php5/apache2/php.ini on line 3

But these are the first 15 lines of /etc/php5/apache2/php.ini:

[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.

; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
; 4. Current working directory (except CLI)
; 5. The web server's directory (for SAPI modules), or directory of PHP

The first uncommented lines of php.ini:

engine = On

short_open_tag = Off

asp_tags = Off

precision = 14

y2k_compliance = On

I thought it would be a caching problem, but I've just disabled my PHP caching (it was APC)

I can't find any (s that aren't in comments in the entire file.

How else could PHP think that there is a ( in the file when there isn't?

; in php.ini means comment line . Message does not count comment lines. So line 3 means 3rd line after top comments.

EDIT 1 : Be sure your are opening right php.ini file which PHP really use

EDIT 2 : use phpinfo(); and at the result page see Loaded Configuration File value. it shows you php.ini file which currently using. Note: restart your apache

I try to imitate your situation:

~]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/phar.ini,
/etc/php.d/zip.ini

So I go to /etc/php.ini and uncomment one of the lines line with a "("

~]$ vi /etc/php.ini
[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.

; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
; 4. Current working directory (except CLI)
; 5. The web server's directory (for SAPI modules), or directory of PHP
 (otherwise in Windows)
; 6. The directory from the --with-config-file-path compile time option, or the

Now I check if there is an error notice:

~]$ php --ini
PHP:  syntax error, unexpected '(' in /etc/php.ini on line 16
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini

Yes, and error, but it shows the correct line number, not ignoring the commented lines. I also got the same error message in apache/error_log when I restarted apache.

PHP:  syntax error, unexpected '(' in /etc/php.ini on line 16

The php files worked, but did not send the error about ini to the log.

So, why don't you edit your /etc/php5/apache2/php.ini? Just erase several lines and see if the error message moves to a different number.

Make sure to restart apache after changing it.