0

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.

2
  • Try putting error_reporting(E_ERROR | E_PARSE); after <?php to avoid warnings. Commented Aug 23, 2019 at 15:40
  • Possible duplicate of Turn Off Display Error PHP.ini Commented Aug 23, 2019 at 17:13

2 Answers 2

0

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();
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.