Solved

Syntax error in php.ini

Posted on 2015-02-20
9
335 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 42

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 42

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 42

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 42

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

12 Experts available now in Live!

Get 1:1 Help Now