Solved

Syntax error in php.ini

Posted on 2015-02-20
9
366 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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
 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Number of reviews not counting correctly 2 22
Ajax php search with multiple text fields generated by php 38 72
Inserting data into database 10 36
Wordpress Query 5 27
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…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

821 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