Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18666

Re: set_error_handler(): duplicate error

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: set_error_handler(): duplicate error
Date 2021-06-20 13:02 +0200
Message-ID <ij8ligFp9b6U1@mid.individual.net> (permalink)
References <s9ski4$42b$2@gioia.aioe.org> <iiu6nlForanU1@mid.individual.net> <sai4vp$11n3$1@gioia.aioe.org> <sajj55$jqj$1@jstuckle.eternal-september.org>

Show all headers | View raw


Jerry Stuckle:

[...]
> set_error_handler() requires a real function as its parameter, not 
> something dynamically defined.

set_error_handler() requires a *callable* not a function. An anonymous
function is just fine - as this *is* a callable. This applies to *every*
function in PHP which wants a callable and is quite handy to avoid
declaring new functions if you just need it once for a specific callback:

-------------------------------------------

<?php
$array = [
    [ 'x' => 1, 'y' => 2 ],
    [ 'x' => 6, 'y' => 1 ],
    [ 'x' => 3, 'y' => 7 ],
];

usort(
    $array,
    function($a, $b) {
        if ($a['x'] == $b['x']) {
            return 0;
        } else if ($a['x'] > $b['x']) {
            return 1;
        } else {
            return -1;
        }
    }
);

print_r($array);

-------------------------------------------

Result:

Array
(
    [0] => Array
        (
            [x] => 1
            [y] => 2
        )

    [1] => Array
        (
            [x] => 3
            [y] => 7
        )

    [2] => Array
        (
            [x] => 6
            [y] => 1
        )

)



-- 
Arno Welzel
https://arnowelzel.de

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-10 11:04 +0200
  Re: set_error_handler(): duplicate error Ii Ii <ya12983@mail.com> - 2021-06-16 02:39 -0700
  Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-16 13:48 +0200
    Re: set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-18 14:53 +0200
      Re: set_error_handler(): duplicate error Jerry Stuckle <jstucklex@attglobal.net> - 2021-06-18 22:00 -0400
        Re: set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-19 16:41 +0200
          Re: set_error_handler(): duplicate error Jerry Stuckle <jstucklex@attglobal.net> - 2021-06-19 19:21 -0400
            Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-20 13:10 +0200
        Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-20 13:02 +0200
      Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-20 12:51 +0200
        Re: set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-21 17:06 +0200
          Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-21 19:43 +0200
            Re: set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-22 16:10 +0200
              Re: set_error_handler(): duplicate error "J.O. Aho" <user@example.net> - 2021-06-22 18:13 +0200
                Re: set_error_handler(): duplicate error alex <1j9448a02@lnx159sneakemail.com.invalid> - 2021-06-23 13:35 +0200
              Re: set_error_handler(): duplicate error Arno Welzel <usenet@arnowelzel.de> - 2021-06-23 10:24 +0200

csiph-web