Hướng dẫn hide error php - ẩn lỗi php

I just want to only turn on PHP errors and disable all notices and warnings in PHP files.

Nội dung chính ShowShow

  • Warning Cakephp là gì?
  • Các bước thực hiện ẩn cảnh báo lỗi Cakephp như sau
  • Bước 1: Login Hosting trên trình duyệt
  • Bước 2: Xác định đường dẫn đến thư mục cần chỉnh sửa
  • Bước 3: Tìm và chỉnh sửa đoạn mã ẩn cảnh báo
  • Bước 4: kiểm tra lại

Nội dung chính

  • Warning Cakephp là gì?
  • Các bước thực hiện ẩn cảnh báo lỗi Cakephp như sau
  • Bước 1: Login Hosting trên trình duyệt
  • Bước 2: Xác định đường dẫn đến thư mục cần chỉnh sửa
  • Bước 3: Tìm và chỉnh sửa đoạn mã ẩn cảnh báo
  • Bước 4: kiểm tra lại

Hướng dẫn hide error php - ẩn lỗi php

Nội dung chínhDec 28, 2011 at 7:07

1

asked Dec 28, 2011 at 7:07

# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0

It is probably not the best thing to do. You need to at least check out your PHP error log for things going wrong ;)Dec 28, 2011 at 7:14

answered Dec 28, 2011 at 7:14imp

impimp7 silver badges13 bronze badges

5

1,0907 silver badges13 bronze badges

If you are in a shared hosting plan that doesn't have PHP installed as a module you will get a 500 server error when adding those flags to the .htaccess file.

ini_set('display_errors','off');

But you can add the line

on top of your .php file and it should work without any errors.Sep 9, 2012 at 1:05

answered Sep 9, 2012 at 1:05Fortes

FortesFortes12 silver badges23 bronze badges

Try:

php_value error_reporting 2039

It is probably not the best thing to do. You need to at least check out your PHP error log for things going wrong ;)Dec 28, 2011 at 7:14

answered Dec 28, 2011 at 7:14Sudhir Bastakoti

impimp15 gold badges156 silver badges161 bronze badges

5

1,0907 silver badges13 bronze badges

If you are in a shared hosting plan that doesn't have PHP installed as a module you will get a 500 server error when adding those flags to the .htaccess file.

But you can add the line

ini_set('display_errors','off');

on top of your .php file and it should work without any errors.

answered Sep 9, 2012 at 1:05Apr 17, 2013 at 8:53

FortesFortesRich

91812 silver badges23 bronze badges1 silver badge1 bronze badge

Use:

ini_set('display_errors','off');

Sudhir BastakotiSudhir Bastakoti

97.8k15 gold badges156 silver badges161 bronze badgesDec 4, 2015 at 5:10

2

Fortes is right, thank you.

When you have a shared hosting it is usual to obtain an

php_value error_reporting 2039
4.Apr 30, 2013 at 14:33

Warning Cakephp là gì?

I have a website with Joomla and I added to the

php_value error_reporting 2039
5:

The error line showed in my website disappeared.

Các bước thực hiện ẩn cảnh báo lỗi Cakephp như sau

answered Apr 17, 2013 at 8:53

RichRich

Bước 1: Login Hosting trên trình duyệt

691 silver badge1 bronze badge

It is working fine in WordPress'

php_value error_reporting 2039
6.

Bước 2: Xác định đường dẫn đến thư mục cần chỉnh sửa

Bước 3: Tìm và chỉnh sửa đoạn mã ẩn cảnh báo

app/Config/core.php

Bước 4: kiểm tra lại

Nội dung chính

Bước 3: Tìm và chỉnh sửa đoạn mã ẩn cảnh báo

Bước 4: kiểm tra lạicore.php

Nội dung chính

asked Dec 28, 2011 at 7:07

Bước 4: kiểm tra lại

Nội dung chính

asked Dec 28, 2011 at 7:07

It is probably not the best thing to do. You need to at least check out your PHP error log for things going wrong ;)

answered Dec 28, 2011 at 7:14

impimp

Tôi chỉ muốn chỉ bật lỗi PHP và vô hiệu hóa tất cả các thông báo và cảnh báo trong các tệp PHP.

Nội phân Chính showShow

  • Cảnh báo CakePhp Là Gì?
  • Các bước thực hiện ẩn cảnh báio lỗi cakephp NH
  • BướC 1: Đăng nhập lưu trữ trên trình Duyệt
  • BướC 2: Xác Đu
  • Bước 3: tìm và ChỉNH Sửa Đoạn MÃ
  • BướC 4: Kiểm Tra Lại
  • Ví dụ đầy đủ:
  • Hoặc đơn giản là (cùng một hiệu ứng):
  • Kiểm tra thông tin được cập nhật của bạn trong tệp php.ini
  • Sử dụng Windows Explorer:
  • Sử dụng bảng điều khiển XAMPP
  • Tôi có thể tạo phpinfo của riêng tôi () không? Có bạn có thể
  • Cách đặt Display_errors thành Tắt trong tệp của riêng tôi mà không cần sử dụng Php.ini
  • Để kiểm tra đầu ra mà không cần truy cập vào tệp php.ini

Đã trả lời ngày 30 tháng 7 năm 2020 lúc 23:50

  • Cảnh báo CakePhp Là Gì?
  • Các bước thực hiện ẩn cảnh báio lỗi cakephp NH
  • BướC 1: Đăng nhập lưu trữ trên trình Duyệt
  • BướC 2: Xác Đu
  • Bước 3: tìm và ChỉNH Sửa Đoạn MÃ
  • BướC 4: Kiểm Tra Lại

Đã trả lời ngày 30 tháng 7 năm 2020 lúc 23:50

  • Cảnh báo CakePhp Là Gì?
  • Các bước thực hiện ẩn cảnh báio lỗi cakephp NH
  • BướC 1: Đăng nhập lưu trữ trên trình Duyệt
  • BướC 2: Xác Đu
  • Bước 3: tìm và ChỉNH Sửa Đoạn MÃ
  • BướC 4: Kiểm Tra Lại

Ví dụ đầy đủ:Dec 28, 2011 at 7:07

1

Hoặc đơn giản là (cùng một hiệu ứng):

# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0

Nội phân chínhDec 28, 2011 at 7:14

Hỏi ngày 28 tháng 12 năm 2011 lúc 7:07imp

Nó có lẽ không phải là điều tốt nhất để làm. Bạn cần ít nhất hãy kiểm tra nhật ký lỗi PHP của bạn cho những điều không ổn;)7 silver badges13 bronze badges

5

Đã trả lời ngày 28 tháng 12 năm 2011 lúc 7:14

không muốn

ini_set('display_errors','off');

1.0907 Huy hiệu bạc13 Huy hiệu đồng

Nếu bạn đang ở trong một gói lưu trữ được chia sẻ mà không cài đặt PHP như một mô -đun, bạn sẽ gặp lỗi 500 máy chủ khi thêm các cờ đó vào tệp .htaccess.Sep 9, 2012 at 1:05

Nhưng bạn có thể thêm dòngFortes

Trên đầu tệp .php của bạn và nó sẽ hoạt động mà không có bất kỳ lỗi nào.12 silver badges23 bronze badges

Try:

php_value error_reporting 2039

Nội phân chínhDec 28, 2011 at 7:14

Hỏi ngày 28 tháng 12 năm 2011 lúc 7:07Sudhir Bastakoti

Nó có lẽ không phải là điều tốt nhất để làm. Bạn cần ít nhất hãy kiểm tra nhật ký lỗi PHP của bạn cho những điều không ổn;)15 gold badges156 silver badges161 bronze badges

5

Đã trả lời ngày 28 tháng 12 năm 2011 lúc 7:14

không muốn

1.0907 Huy hiệu bạc13 Huy hiệu đồng

ini_set('display_errors','off');

Nếu bạn đang ở trong một gói lưu trữ được chia sẻ mà không cài đặt PHP như một mô -đun, bạn sẽ gặp lỗi 500 máy chủ khi thêm các cờ đó vào tệp .htaccess.

Nhưng bạn có thể thêm dòngApr 17, 2013 at 8:53

Trên đầu tệp .php của bạn và nó sẽ hoạt động mà không có bất kỳ lỗi nào.Rich

Đã trả lời ngày 9 tháng 9 năm 2012 lúc 1:051 silver badge1 bronze badge

Use:

ini_set('display_errors','off');

Fortesfortes

91812 Huy hiệu bạc23 Huy hiệu đồngDec 4, 2015 at 5:10

2

Sudhir Bastakotisudhir Bastakoti

97.8K15 Huy hiệu vàng156 Huy hiệu bạc161 Huy hiệu ĐồngApr 30, 2013 at 14:33

Cảnh báo CakePhp Là Gì?

Các bước thực hiện ẩn cảnh báio lỗi cakephp NH

website lỗi nhìn sẽ như thế này!

Các bước thực hiện ẩn cảnh báo lỗi Cakephp như sau

Bạn cần có quyền truy cập Hosting / FTP / SSH để sửa nhé

ở hướng dẫn này, mính sẽ demo trên giao diện web Hosting DirectAdmin

Bước 1: Login Hosting trên trình duyệt

Điều này khỏi cần hướng dẫn nhé. các Bạn tự login vào Hosting

Với FTP và SSH các Bạn cũng login nha

Bước 2: Xác định đường dẫn đến thư mục cần chỉnh sửa

Thường thì config sẽ nằm trong đường dẫn này

app/Config/core.php

tất nhiên đây là đường dẫn trong thư mục public_html nhé. Hãy chọn cho đúng tên miền cần chỉnh sửa nếu Bạn có nhiều tên miền. Tránh nhầm lẫn nha

Một số lập trình viên chỉnh sửa thì Bạn tự tìm file tương ứng nhé

Bước 3: Tìm và chỉnh sửa đoạn mã ẩn cảnh báo

Như ảnh bước 2, các Bạn click vào nút “edit” của hàng core.phpcore.php

Sau đó dùng tổ hợp phím crtl + F (tìm kiếm) và paste vào cụm từ này “

php_value error_reporting 2039
8”

Sau đó chỉnh sửa “2” thành “0”

Bước 4: kiểm tra lại

Hãy truy cập website xem đã hết lỗi chưa nhé

Nếu chưa, vui lòng chat với kỹ thuật tại HostingViet.vn

Chúng tôi luôn trực 24/24 để hỗ trợ Quý khách và các Bạn

Chúc các Bạn thành công!

Trung – Kỹ thuật viên HostingViet

I am trying to turn off all errors on my website. I have followed different tutorials on how to do this, but I keep getting read and open error messages. Is there something I am missing?

I have tried the following in my php.ini file:

ini_set('display_errors','off');
0

For some reason when I do a fileopen() call for a file which does not exist, I still get the error displayed. This is not safe for a live website, for obvious reasons.

asked Apr 11, 2013 at 12:52Apr 11, 2013 at 12:52

3

I always use something like this in a configuration file:

ini_set('display_errors','off');
1

This allows easy toggling between debug settings. You can improve this further by checking on which server the code is running (development, test, acceptance, and production) and change your settings accordingly.

Note that no errors will be logged if error_reporting is set to 0, as cleverly remarked by Korri.

answered Apr 11, 2013 at 12:59Apr 11, 2013 at 12:59

SherlockSherlockSherlock

7,4076 gold badges36 silver badges79 bronze badges6 gold badges36 silver badges79 bronze badges

4

You should consider not displaying your error messages instead!not displaying your error messages instead!

Set

ini_set('display_errors','off');
4 in your PHP code (or directly into your ini file if possible), and leave error_reporting on
ini_set('display_errors','off');
5 or whatever kind of messages you would like to find in your logs.

This way you can handle errors later, while your users still don't see them.

Full example:

ini_set('display_errors','off');
2

Or simply (same effect):

ini_set('display_errors','off');
3

answered Feb 11, 2014 at 10:52Feb 11, 2014 at 10:52

LeviteLeviteLevite

16.6k7 gold badges50 silver badges50 bronze badges7 gold badges50 silver badges50 bronze badges

2

In

ini_set('display_errors','off');
6, comment out:

ini_set('display_errors','off');
4

By placing a

ini_set('display_errors','off');
7 ahead of it (i.e., like
ini_set('display_errors','off');
8)

For disabling in a single file, place

ini_set('display_errors','off');
9 after opening a
ini_set('display_errors','off');
0 tag.
, place
ini_set('display_errors','off');
9 after opening a
ini_set('display_errors','off');
0 tag.

answered Apr 11, 2013 at 13:01Apr 11, 2013 at 13:01

Vishnu RVishnu RVishnu R

1,8493 gold badges25 silver badges45 bronze badges3 gold badges25 silver badges45 bronze badges

1

In file php.ini you should try this for all errors:

ini_set('display_errors','off');
5

Urs

4,8847 gold badges50 silver badges113 bronze badges7 gold badges50 silver badges113 bronze badges

answered Apr 1, 2014 at 15:45Apr 1, 2014 at 15:45

1

Let me quickly summarize this for reference:

  • ini_set('display_errors','off');
    
    1 adapts the currently active setting for the default error handler.

  • Editing the error reporting ini options also changes the defaults.

    • Here it's imperative to edit the correct

      ini_set('display_errors','off');
      
      6 version - it's typically
      ini_set('display_errors','off');
      
      3 on modern servers,
      ini_set('display_errors','off');
      
      4 alternatively; while the CLI version has a distinct one.

    • Alternatively you can use depending on SAPI:

      • mod_php:
        ini_set('display_errors','off');
        
        5 with
        ini_set('display_errors','off');
        
        6 options
      • FastCGI: commonly a local
        ini_set('display_errors','off');
        
        6
      • And with PHP above 5.3 also a
        ini_set('display_errors','off');
        
        8
    • Restarting the webserver as usual.

If your code is unwieldy and somehow resets these options elsewhere at runtime, then an alternative and quick way is to define a custom error handler that just slurps all notices/warnings/errors up:

ini_set('display_errors','off');
6

Again, this is not advisable, just an alternative.

answered Jul 30, 2014 at 1:16Jul 30, 2014 at 1:16

mariomariomario

142k20 gold badges236 silver badges285 bronze badges20 gold badges236 silver badges285 bronze badges

2

In file php.ini you should try this for all errors:

ini_set('display_errors','off');
7

Urs

  • 4,8847 gold badges50 silver badges113 bronze badges
  • answered Apr 1, 2014 at 15:45

Let me quickly summarize this for reference:Mar 10, 2015 at 4:26

1

ini_set('display_errors','off');
1 adapts the currently active setting for the default error handler.

ini_set('display_errors','off');
8

Editing the error reporting ini options also changes the defaults.

ini_set('display_errors','off');
9

Here it's imperative to edit the correct

ini_set('display_errors','off');
6 version - it's typically
ini_set('display_errors','off');
3 on modern servers,
ini_set('display_errors','off');
4 alternatively; while the CLI version has a distinct one.Apr 11, 2013 at 12:54

Alternatively you can use depending on SAPI:Tim S.

mod_php:

ini_set('display_errors','off');
5 with
ini_set('display_errors','off');
6 options7 gold badges43 silver badges71 bronze badges

1

FastCGI: commonly a local

ini_set('display_errors','off');
6

And with PHP above 5.3 also a

ini_set('display_errors','off');
8

Restarting the webserver as usual.Mar 10, 2015 at 4:33

If your code is unwieldy and somehow resets these options elsewhere at runtime, then an alternative and quick way is to define a custom error handler that just slurps all notices/warnings/errors up:Vladimir Ramik

Again, this is not advisable, just an alternative.2 gold badges12 silver badges23 bronze badges

Mở tệp php.ini của bạn (nếu bạn đang sử dụng Linux - sudo vim /etc/php5/apache2/php.ini)

Thêm dòng này vào tệp đó

php_value error_reporting 2039
0

.E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING)

php_value error_reporting 2039
1

Và cuối cùng bạn cần khởi động lại máy chủ Apache của mình.

Đã trả lời ngày 5 tháng 1 năm 2016 lúc 9:26Jan 5, 2016 at 9:26

UWU_SANDUNUWU_SANDUNUWU_SANDUN

1.05713 Huy hiệu bạc18 Huy hiệu đồng13 silver badges18 bronze badges

Nó là không đủ trong trường hợp PHP FPM. Đó là một tệp cấu hình nữa có thể cho phép

# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
1. Bạn nên tìm www.conf. Trong trường hợp của tôi, nó nằm trong thư mục /etc/php/7.1/fpm/pool.d/www.conf. In my case it is in directory /etc/php/7.1/fpm/pool.d/

Bạn nên tìm

# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
2 và vô hiệu hóa nó,
# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
3. Điều này sẽ giải quyết vấn đề.

Đã trả lời ngày 25 tháng 1 năm 2019 lúc 16:55Jan 25, 2019 at 16:55

Vazgen Manukyanvazgen ManukyanVazgen Manukyan

1.3701 Huy hiệu vàng11 Huy hiệu bạc17 Huy hiệu đồng1 gold badge11 silver badges17 bronze badges

Đã khá lâu và câu trả lời của Iam chắc chắn đã bị xóa. Nếu bất kỳ người dùng mới nào vẫn đang tìm kiếm câu trả lời và cuộn đến nay, thì đây là ở đây.

Kiểm tra thông tin được cập nhật của bạn trong tệp php.ini

Sử dụng Windows Explorer:

php_value error_reporting 2039
2

Sử dụng bảng điều khiển XAMPP

  1. Nhấp vào nút cấu hình cho 'Apache' (Dừng | Quản trị viên | Cấu hình | nhật ký)
  2. Chọn PHP (php.ini)

Tôi có thể tạo phpinfo của riêng tôi () không? Có bạn có thể

  1. Tạo trực tiếp phpinfo.php trong root của bạn hoặc bất cứ nơi nào bạn muốn
  2. Đặt cái này
    # PHP error handling for development servers
    php_flag display_startup_errors off
    php_flag display_errors off
    php_flag html_errors off
    php_flag log_errors on
    php_flag ignore_repeated_errors off
    php_flag ignore_repeated_source off
    php_flag report_memleaks on
    php_flag track_errors on
    php_value docref_root 0
    php_value docref_ext 0
    php_value error_log /home/path/public_html/domain/PHP_errors.log
    php_value error_reporting -1
    php_value log_errors_max_len 0
    
    4
  3. Lưu các tập tin.
  4. Mở tệp và bạn sẽ xem tất cả các chi tiết.

Cách đặt Display_errors thành Tắt trong tệp của riêng tôi mà không cần sử dụng Php.ini

Bạn có thể làm điều này bằng cách sử dụng hàm

# PHP error handling for development servers
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /home/path/public_html/domain/PHP_errors.log
php_value error_reporting -1
php_value log_errors_max_len 0
5. Đọc thêm về ini_set () tại đây (https://www.php.net/manual/en/function.ini-set.php)

  1. Truy cập tiêu đề của bạn.php hoặc index.php
  2. Thêm mã này
    # PHP error handling for development servers
    php_flag display_startup_errors off
    php_flag display_errors off
    php_flag html_errors off
    php_flag log_errors on
    php_flag ignore_repeated_errors off
    php_flag ignore_repeated_source off
    php_flag report_memleaks on
    php_flag track_errors on
    php_value docref_root 0
    php_value docref_ext 0
    php_value error_log /home/path/public_html/domain/PHP_errors.log
    php_value error_reporting -1
    php_value log_errors_max_len 0
    
    6

Để kiểm tra đầu ra mà không cần truy cập vào tệp php.ini

php_value error_reporting 2039
3

Đã trả lời ngày 30 tháng 7 năm 2020 lúc 23:50Jul 30, 2020 at 23:50

DexterDexterDexter

6.4723 Huy hiệu vàng35 Huy hiệu bạc34 Huy hiệu đồng3 gold badges35 silver badges34 bronze badges