Cara menggunakan php_admin_value error_reporting

Menampilkan PHP errors dari website dan mengaktifkan PHP error display dari pesan error 500

Cara menggunakan php_admin_value error_reporting

Ditulis oleh Shinta Theofani
Diperbarui lebih dari seminggu yang lalu

Ikuti panduan di bawah ini untuk menampilkan notifikasi error melalui hPanel dan WordPress.

Bagaimana cara mengaktifkan PHP error display dan login di hPanel?

Di hPanel, Anda dapat memilih untuk langsung menampilkan PHP error di website atau menyimpannya di log file.

Caranya, login ke control panel, kemudian HostingKelolaKonfigurasi PHP:

Cara menggunakan php_admin_value error_reporting

Setelah itu pilih Opsi PHP, dan beri centang pada salah satu opsi tampilan PHP error yang diinginkan.

  • display_errors untuk menampilkan error di website

  • log_errors untuk membuat file khusus berisi PHP error

Cara menggunakan php_admin_value error_reporting

Setelah itu, klik Simpan 😊

CATATAN:

  • Dimana saya bisa menemukan error log website? (dalam Bahasa Inggris)

Bagaimana cara mengaktifkan error display di WordPress?

Jika Anda menggunakan WordPress, buka File Manager dan temukan file public_html/wp-config.php. Periksa file tersebut memiliki baris seperti ini:

define('WP_DEBUG', false);

Kemudian, ubah "false" menjadi "true", dan tambahkan baris ini:

define('WP_DEBUG_DISPLAY', true);


Selesai! Sekarang PHP error tidak akan muncul di website WordPress Anda😊

Bagaimana cara mengaktifkan error display melalui .htaccess?

Agar dapat melakukan logging PHP error di file error_log, tambahkan baris di bawah ini di file .htaccess:

# log PHP errors to a file
php_flag log_errors on
php_value error_reporting 32767
php_value error_log "error_log.txt"

PENTING: Pastikan untuk membuat backup dari file .htaccess terdahulu sebelum menerapkan beberapa perubahan. Pengaturan yang salah dapat menyebabkan website Anda tidak dapat diakses.

CATATAN:

  • Opsi di atas hanya akan menampilkan PHP error seperti Warning, Deprecated, Notice, dan lainnya. Error lain seperti 503 atau Error establishing database connection tidak termasuk PHP error, dan tidak akan dicatat di log.

  • Bagaimana cara menonaktifkan notifikasi error PHP?

Article guide you to PHP enable warnings and PHP disable warnings/errors. Whereas it can possible with htaccess display_error off (error reporting off) method.

Table of Contents

  • But, why to disable PHP warning in htaccess?
  • How to turn off PHP warning messages?
  • Steps you need to follow to remove PHP warnings with .htaccess
  • Code: php_flag display_errors off
  • Reader Interactions
  • How do I turn off PHP warnings?
  • How do I hide PHP warnings and notices in WordPress?
  • Where are PHP error logs cPanel?

Enabling PHP warnings via .htaccess file is useful when you initially developing and debugging your websites. But once website development is completed you should turn off PHP warnings.

But, why to disable PHP warning in htaccess?

Untrusted sources can see detailed web application environment error messages. In which having sensitive information that can be used for attack.

Error messages can reveal information about your website, such as path information and variables. That can be used by attacker to hack your website or web application. So you can check here and secure site by migrating HTTP to HTTPS.

Let’s see how to secure your important information by turning off PHP warning.

How to turn off PHP warning messages?

It is highly recommended to turn off PHP warnings in htaccess in order to avoid leakage of important information.

You can disable PHP warnings using display_errors from your .htaccess file.

Steps you need to follow to remove PHP warnings with .htaccess

1] Login into your cPanel account.

2] Select File Manager in File Section.

3] Click on the settings.

4] Enable check box “Show hidden files”.

5] Select .htaccess file and click on Edit option.

6] Add single a line in .htaccess file and click on Save Changes.

Code: php_flag display_errors off

We should disable PHP warning in .htaccess because,

  • Common information is displayed in error massage like path location if we don’t turn off PHP warning.
  • Attacker can visualize how your website is designed and structured, and make assumptions on where critical files are stored with the help of path locations.
  • Path location expose Webroot path that can help attacker to gain illegal access to the site.

In this way you can turn off warning messages in PHP using .htaccess file cPanel and can protect your website from Hacker.

If you have any doubts or any problems then please let us know through your comment, we will defineatly try to solve your problems.

For additional information you can click here and learn how to secure your website from hacker.

Reader Interactions

How do I turn off PHP warnings?

Remember, the PHP ini configuration has an error_reporting directive that will be set by this function during runtime. error_reporting(0); To remove all errors, warnings, parse messages, and notices, the parameter that should be passed to the error_reporting function is zero.

How do I hide PHP warnings and notices in WordPress?

Either way, you're looking for the “WP_DEBUG” portion of the wp-config. php file. Click the “Save Changes” button in the top right. Once the file is saved, this will disable the PHP warnings in WordPress.

Where are PHP error logs cPanel?

cPanel Error Log Login into your cPanel. Go to Metrics > Errors. Your error log will display in the box.