I'm having trouble getting php -l(the built in linter) to actually recognize that the file it's linting has issues. I'm on Mac OS X Lion, running php 5.3.8. I verified through the command line (php -i) that display_errors is set to On and error_reporting is set to E_ALL | E_STRICT.
Here is my test file, I've tried others with the same result:
<?php
abcde
for {
?>
running that through php -l nets the response:
No syntax errors detected in test.php
Are you sure you edited correct php.ini? Confirm it with phpinfo()
Related
VmWare Cloud Server
CentOS Linux 7.6.1810 - Php 5.6.40 - Apache/2.4.6
test.php
<?php
echo($x);
phpinfo();
?>
Output :
Notice: Undefined variable x in /var/www/html/test.php on line 1
In CORE section of phpinfo output I have
display_errors Off
display_startup_errors Off
error_reporting 0
Why Notice is shown?
I'd like not to show any error/notice/warning etc.
It's possible that your settings are controlled in the htaccess file, see more info: https://www.php.net/manual/en/configuration.changes.php
But you can try this:
<?php
ini_set('display_errors', 0);
echo($x);
phpinfo();
Try adding the following at the top of your PHP script :
<?php error_reporting(0); ?>
If the notice disappears, I would suggest making sure you are modifying the good php.ini file.
I'm programming in php on my machine where I freshly installed:
Centos 6: centos-release-6-10.el6.centos.12.3.x86_64
Php 7 - PHP 7.0.31 (cli) (built: Jul 17 2018 15:40:48) ( NTS ) (Zen Engine 3.0.0)
Apache 2 - Server version: Apache/2.2.15 (Unix)
As fresh install nothing were logged. (first time this happens)
My php info tell me I have /etc/php.ini configuration file, where I have:
error_reporting = E_ALL
display_errors = Off
display_startup_errors = On
log_errors = On
log_errors_max_len = 0
html_errors = On
error_log = /var/log/httpd/php-error.log
On php info I see correct variables as wrote here.
In httpd.conf
ErrorLog "/var/log/httpd/error_log"
LogLevel debug
There is no ovewrite configuration in my virtualhost. I just tried debug to fix this issue, but nothing.
To make sure for me that anything can have access to log path, I used chmod 777 on the folders /var, /var/log, /var/log/httpd, and on error.log apache file. I didn't on php error file since it's not present, and as far as I know, Apache (or php) sould create it on it's own.
My php has eveident errors, and on different environment (with php 5) is naturally logged on apache log file.
I obviously restarted apache service at any change.
I searched really a lot before asking, and nothing that was suggested has never worked.
Am I really missing something?
Thanks. Riccardo
Update: After the best badge I could have earned: "Tumbleweed", I want to update with something more I tried:
I tried with code inside the php file:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
And nothing was logged.
display_errors = on in php.ini
This didn't work either
I'm really struggling programming without a error log...
Thanks to anyone.
Finally I got what was the problem.
Well.. maybe it is just MY problem...
By the way, with php 7.0 I had a php.ini corrupted file, I didn't see it had a lot of strange character.
I had to correct all the file and everything worked as a charme.
Hope anyone else could benefice from this.
A simple php_curl example isn't working anymore on my Windows 10 laptop. It was working before.
Fatal error: Uncaught Error: Call to undefined function curl_init() in C:\Users\path\curl.php:3 Stack trace: #0 {main} thrown in C:\Users\path\curl.php on line 3
My C:\php7\php.ini has extension=C:\php7\ext\php_curl.dll
php_curl.dll exists in C:\php7\ext
PHP Version 7.0.30
Windows 10 Pro Version 1607 Build 14393.2189
But my loclahost/phpinfo.php does not have cURL. How come all of a sudden it disappeared ?
PS : The script worked in the command line. It's just that Apache is not loading the extension.
don't know why it suddenly stopped working, but first run <?php phpinfo(~0); , and check which php.ini file that is actually loaded (this avoids editing the wrong php.ini file to no avail) (in this example, it is /etc/php/7.0/fpm/php.ini), then edit that php.ini file, if that file actually has the extension=C:\php7\ext\php_curl.dll line, then some combination of the following settings are set wrong:
display_startup_errors is Off, change it to On
display_errors is Off, change it to On
error_reporting is not E_ALL, change it to error_reporting=E_ALL (and nothing else, not like error_reporting= E_ALL & ~E_NOTICE or whatever, just E_ALL)
html_errors is Off, change it to On
then restart apache, again check the phpinfo() page, and verify that the new configuration options are actually loaded, then run <?php curl_init();, and it should show an error about why the curl extension could not be loaded.
I came across some links on other StackOverflow answers (will post the links here if I trace them again). I had Apache 2.4.23 Win64 - I reinstalled Apache to the latest one - 2.4.33 Win64 - and now cURL is working.
PHP 7 does not return any errors only server error 500. I set error reporting to development machine but error file/screen is still empty. For example:
echo 'test'; output is test
but ech 'test'; (incorect) returns server error 500
i have tried already:
ini_set('display_errors',true);
and
ini_set('error_reporting', E_ALL);
but nothing happens.
IIS8
PHP7
I had the exact same issue too, upgrading from the IIS supported 5.x to 7.0.9. Here's the trick. By default the php.ini in 7.x does not have logging enabled:
1) Create a blank file with write permissions from IIS (IUSR in Windows 10)
2) Edit your php.ini and remove the semicolon ';' and update the error_log variable:
; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
error_log = C:\path\to\file\errors.log
; Log errors to syslog (Event Log on Windows).
;error_log = syslog
3) Restart IIS service using IIS manager
I get the following error when I transfer my code to a stage env: "PHP Warning: json_encode(): Invalid UTF-8" I do not get this error on my development environment. I am fixing the issue with:
iconv("ISO-8859-1", "UTF-8", $value);
but I would like to be able to resolve the issue at the "development" stage and not in my "staging" env. I'm wondering if perhaps I have some setting in either dev to ignore this warning? Both php.ini have the same:
error_reporting = E_ALL & ~E_DEPRECATED
The development env is:
Windows 8
IIS 8.0
PHP 5.4.15
SQL Server 2008
Stage Env:
Windows Server 2008
IIS 7.5
PHP 5.4.15
SQL Server 2008
Both environments connect to the same application_stage database on the same SQL Server 2008 database server.
Any help would be appreciated.
Could you show your php array(). Your problem might be in a value in your array.