Hướng dẫn php ignore errors - php bỏ qua lỗi

Bạn có thể, nhưng tôi sẽ cảnh báo: Nhiều người coi phương pháp này khá xấu xa.

// https://stackoverflow.com/a/66377817/578023
function is_same(&$a, &$b): bool {
    $_ = [ &$a, &$b ];
    return
        \ReflectionReference::fromArrayElement($_, 0)->getId() ===
        \ReflectionReference::fromArrayElement($_, 1)->getId();
}

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    resume:
    try{
        foreach($collection as $item){
            if($resuming && !is_same($cursor,$item) ){
                continue;                   // some things have better ways to skip ahead, especially an array index
            }
            else {
                $resuming = false;
                $cursor=&$item;             // main concept is to remember where you are in the iteration
            }                               // in some situation you may have to use references,  &item
            

            // your normal loop here
            .
            .
            .
        }
    }   catch( Exception $e){
        $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        if($resuming)
            goto resume;
    }
    
    unset($cursor);
    
}

Lý tưởng nhất là tốt nhất là kết thúc cuộc gọi

# 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 trong một khối
# 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, nhưng thật lòng mà nói, tôi không chắc cách chơi với Goto.

Nếu nó thực hiện vì Goto đã phá vỡ dòng chảy thì bạn sẽ cần một số logic có điều kiện, vì vậy con trỏ vẫn tồn tại. Nếu bạn có câu lệnh trả về bên trong vòng lặp, bạn phải sử dụng khối cuối cùng để gọi đế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 - hoặc gây rò rỉ bộ nhớ.

Sau đó, một lần nữa, trong khi ít thú vị hơn, bạn có thể thực hiện mánh khóe này bằng cách chỉ làm tổ toàn bộ vòng lặp của bạn trong

# 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. Mặc dù điều đó không thực sự đảo ngược việc thực hiện của bạn, nhưng nó thực hiện chính xác hiệu ứng tương tự mà không có nguy cơ Goto.

# 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 từ https://stackoverflow.com/a/66377817/578023

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}

Một phương pháp cuối cùng, không hình; Bạn có thể sử dụng Php's

# 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,
# 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
7,
# 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
8,
# 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
9,
ini_set('display_errors','off');
0

Thay vào đó, những điều này sẽ cho phép bạn chỉ cần có khối thử/bắt bên trong một khối mã mà lặp lại dưới dạng vòng lặp - sau đó sử dụ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
7 trong Catch để thử lại.

Làm cách nào để bỏ qua các lỗi PHP?

Bỏ qua các lỗi PHP cho phép bạn có chọn lọc báo cáo lỗi khi bạn nghĩ rằng nó có thể xảy ra với cú pháp @. Do đó, nếu bạn muốn mở một tệp có thể không tồn tại và triệt tiêu bất kỳ lỗi nào phát sinh, bạn có thể sử dụng điều này: $ fp = @fopen ($ file, $ mode);$fp = @fopen($file, $mode);

Mã có tiếp tục sau khi bắt PHP không?

Mã trong khối cuối cùng sẽ luôn được thực thi sau khi thử và bắt các khối, bất kể ngoại lệ có bị ném hay không, và trước khi thực hiện bình thường tiếp tục., regardless of whether an exception has been thrown, and before normal execution resumes.

Làm thế nào tôi có thể bắt được ngoại lệ trong PHP?

Bởi vì các ngoại lệ là các đối tượng, tất cả chúng đều mở rộng một lớp ngoại lệ tích hợp (xem các ngoại lệ ném vào PHP), điều đó có nghĩa là việc bắt mọi ngoại lệ PHP đều đơn giản như loại đối tượng ngoại lệ toàn cầu, được biểu thị bằng cách thêm dấu gạch chéo ngược vào phía trước: thử {// ...} Catch (\ ngoại lệ $ e) {// ...}type-hinting the global exception object, which is indicated by adding a backslash in front: try { // ... } catch ( \Exception $e ) { // ... }

PHP có thể ném là gì?

Có thể ném có thể ném là giao diện cơ sở cho bất kỳ đối tượng nào có thể được ném qua một câu lệnh ném, bao gồm lỗi và ngoại lệ. Lưu ý: Các lớp PHP không thể triển khai giao diện có thể ném trực tiếp và thay vào đó phải mở rộng ngoại lệ.the base interface for any object that can be thrown via a throw statement, including Error and Exception. Note: PHP classes cannot implement the Throwable interface directly, and must instead extend Exception.

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

BướC 1: Đăng nhập lưu trữ trên trình Duyệt

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 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 2: Xác Đu

Bước 3: tìm và ChỉNH Sửa Đoạn MÃ

app/Config/core.php

BướC 4: Kiểm Tra Lại

Ví dụ đầy đủ:

Bước 3: tìm và ChỉNH Sửa Đoạn MÃ

BướC 4: Kiểm Tra Lạicore.php

Ví dụ đầy đủ:

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:

;Error display
display_startup_errors = Off
display_errors = Off
html_errors = Off
docref_root = 0
docref_ext = 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:

// Toggle this to change the setting
define('DEBUG', true);

// You want all errors to be triggered
error_reporting(E_ALL);

if(DEBUG == true)
{
    // You're developing, so you want all errors to be shown
    display_errors(true);

    // Logging is usually overkill during development
    log_errors(false);
}
else
{
    // You don't want to display errors on a production environment
    display_errors(false);

    // You definitely want to log any occurring
    log_errors(true);
}

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');
7 in your PHP code (or directly into your ini file if possible), and leave error_reporting on
ini_set('display_errors','off');
8 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:

define('DEBUG', true);
error_reporting(E_ALL);

if (DEBUG)
{
    ini_set('display_errors', 'On');
}
else
{
    ini_set('display_errors', 'Off');
}

Or simply (same effect):

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
0

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');
9, comment out:

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
1

By placing a

php_value error_reporting 2039
0 ahead of it (i.e., like
php_value error_reporting 2039
1)

For disabling in a single file, place

php_value error_reporting 2039
2 after opening a
php_value error_reporting 2039
3 tag.
, place
php_value error_reporting 2039
2 after opening a
php_value error_reporting 2039
3 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:

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
2

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:

  • php_value error_reporting 2039
    
    4 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');
      
      9 version - it's typically
      php_value error_reporting 2039
      
      6 on modern servers,
      php_value error_reporting 2039
      
      7 alternatively; while the CLI version has a distinct one.

    • Alternatively you can use depending on SAPI:

      • mod_php:
        php_value error_reporting 2039
        
        8 with
        php_value error_reporting 2039
        
        9 options
      • FastCGI: commonly a local
        ini_set('display_errors','off');
        
        9
      • And with PHP above 5.3 also a
        ini_set('display_errors','off');
        
        1
    • 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:

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
3

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:

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
4

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

php_value error_reporting 2039
4 adapts the currently active setting for the default error handler.

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
5

Editing the error reporting ini options also changes the defaults.

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
6

Here it's imperative to edit the correct

ini_set('display_errors','off');
9 version - it's typically
php_value error_reporting 2039
6 on modern servers,
php_value error_reporting 2039
7 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:

php_value error_reporting 2039
8 with
php_value error_reporting 2039
9 options7 gold badges43 silver badges71 bronze badges

1

FastCGI: commonly a local

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

And with PHP above 5.3 also a

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

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

answered Jul 30, 2014 at 1:16

mariomario

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
7

142k20 gold badges236 silver badges285 bronze badgesE_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_WARNING)

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
8

Location file is:

Ubuntu 16.04:/etc/php/7.0/apache2Jan 5, 2016 at 9:26

UWU_SANDUNUWU_SANDUNUWU_SANDUN

CentOS 7:/etc/php.ini13 silver badges18 bronze badges

answered Mar 10, 2015 at 4:26www.conf. In my case it is in directory /etc/php/7.1/fpm/pool.d/

You can also use PHP's

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

If you want to ignore errors from one function only, you can prepend a

ini_set('display_errors','off');
3 symbol.Jan 25, 2019 at 16:55

answered Apr 11, 2013 at 12:54Vazgen Manukyan

Tim S.Tim S.1 gold badge11 silver badges17 bronze badges

13.3k7 gold badges43 silver badges71 bronze badges

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:

function attempt_risky_action($collection){
    $cursor=NULL;
    $resuming = false;
    
    do{
        try{
            foreach($collection as $item){
                if($resuming && !is_same($cursor,$item) ){
                    continue;   
                }
                else {
                    $resuming = false;
                    $cursor=&$item;
                }

                // your loop here
            }
        }   catch( Exception $e){
            $resuming = repair_something($e, $collection);      // returns false if your repair ran out of ideas
        }
        finally{ 
            if(!$resuming){
                unset($cursor); 
            }
        }
    } while($resuming);
}
9

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
    ini_set('display_errors','off');
    
    7
  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

ini_set('display_errors','off');
8.Đọ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
    ini_set('display_errors','off');
    
    9

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

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

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