Solved

Syntax error in php.ini

Posted on 2015-02-20
9
350 Views
Last Modified: 2015-02-21
In my Apache error.log I get
PHP:  syntax error, unexpected '&' in /etc/php5/apache2/php.ini on line 109

What are your personal recommendations on how to suppress these '& messages' in the corresponding lines (here starting at line 108)
   error_reporting
   Default Value: E_ALL & ~E_NOTICE
   Development Value: E_ALL | E_STRICT
   Production Value: E_ALL & ~E_DEPRECATED

Open in new window

0
Comment
Question by:fibo
  • 4
  • 4
9 Comments
 
LVL 35

Assisted Solution

by:Kimputer
Kimputer earned 200 total points
ID: 40621213
php ini should look like this:

error_reporting = E_ALL & ~E_NOTICE

Open in new window


Or the one of the other options. But have it in this format, comment the rest.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 300 total points
ID: 40621327
The lines you mention are part of the documentation and should be preceded with a semi-colon (indicating a comment). Not sure why yours would be uncommented, but add the semi-colon back in and it won't throw the error. If you want to find the proper place for the error_reporting directive, do a search through your php.ini - in mine it's at line 514

;error_reporting
;Default Value: E_ALL & ~E_NOTICE
;Development Value: E_ALL | E_STRICT
;Production Value: E_ALL & ~E_DEPRECATED
0
 
LVL 29

Author Closing Comment

by:fibo
ID: 40621597
Thx. Both comments are solutions, but Chris' is more logical.

Indeed my file has around line 507 all the folowing:
; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED

Open in new window

0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 40621609
Hey fibo.

Thanks for the points.

Be aware of the first solution - if you'd have followed that, then that error_reporting directive would have been overwritten by the proper one later in your php.ini file. You wouldn't get errors, but you'd be banging you head against the wall
wondering why the line at 108 wasn't being implemented properly, no matter what you set it to !
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 29

Author Comment

by:fibo
ID: 40623251
Hi Chris,

Thx for the follow-up.

I presume that some very special version of PHP come with this php.ini, since most of my other sites have the correct setup
(and I am not the only one with this problem!)
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 40623287
I've never come across a php.ini with that part of the file uncommented. Are you sure you (or someone else) has uncommented it by accident.

Just above those lines you'll usually see a few comments explaining that the section is for quick reference. Technically you don't need any of it in there, as it's just commented documentation, but all the php.ini files I've seen have it in.
0
 
LVL 29

Author Comment

by:fibo
ID: 40623307
I am not alone, this is indeed a popular problem:
https://www.google.com/search?q=php.ini+apache2+unexpected+syntax+%22%26%22
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 40623317
Hey fibo,

You can indeed get syntax errors in your php.ini for all sorts of reasons. A couple of the links that you show from google show a similar error to what you had and the response on those pages are all the same as my suggestion - that some of the lines that are meant to be comments had been uncommented.

I've seen in the past where people have been advised to uncomment certain lines in php.ini (to enable an extension, for example) and have simply uncommented the wrong bit.

I have no idea how or why this happened in your case, but it did - at some point :)
0
 
LVL 29

Author Comment

by:fibo
ID: 40623319
Random fiddling with php.ini is out of my safe or trial area, so among all the mistakes I routinely accomplish, this is presumably not one. B-)

You're right that there are many solutions proposed, not all veray clear or confidently trusatble. Hence my asking here, and glad to have had good answers!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Animated .jpg? 13 63
Mysql sync between 3-4 mysql db 4 25
PHP preg_replace code convert to Delphi 14 37
How can I echo a PHP variable in AJAX function? 7 37
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now