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


Groups > comp.lang.php > #18298 > unrolled thread

imap_search(): $charset parameter default value

Started byalex <1j9448a02@lnx159sneakemail.com.invalid>
First post2020-07-14 12:07 +0200
Last post2020-07-14 16:05 +0200
Articles 4 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  imap_search(): $charset parameter default value alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-07-14 12:07 +0200
    Re: imap_search(): $charset parameter default value alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-07-14 12:33 +0200
    Re: imap_search(): $charset parameter default value "J.O. Aho" <user@example.net> - 2020-07-14 14:46 +0200
      Re: imap_search(): $charset parameter default value alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-07-14 16:05 +0200

#18298 — imap_search(): $charset parameter default value

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-07-14 12:07 +0200
Subjectimap_search(): $charset parameter default value
Message-ID<rek04m$1bm$1@gioia.aioe.org>
What is?

I did some tests with null, NIL and 0, but I was unable to reach a 
conclusion.

function test($stream, $criteria, $options) {
     $charsets = [
         null,
         NIL,
         0,
     ];

     foreach ($charsets as $charset) {
         try {
             imap_search(
                 $stream,
                 $criteria,
                 $options,
                 $charset
             );
         } catch (\Throwable $throwable) {
             printf(
                 "%s (%s): %s\n",
                 $charset,
                 gettype($charset),
                 $throwable->getMessage()
             );
         }
     }
}

test(...);

Output:

  (NULL): imap_search() expects parameter 4 to be string, null given
0 (integer): imap_search() expects parameter 4 to be string, int given
0 (integer): imap_search() expects parameter 4 to be string, int given

[toc] | [next] | [standalone]


#18299

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-07-14 12:33 +0200
Message-ID<rek1md$p31$1@gioia.aioe.org>
In reply to#18298
Il 14/07/20 12:07, alex ha scritto:
> What is?
> 
> I did some tests with null, NIL and 0, but I was unable to reach a 
> conclusion.
> 
> function test($stream, $criteria, $options) {
>      $charsets = [
>          null,
>          NIL,
>          0,
>      ];
> 
>      foreach ($charsets as $charset) {
>          try {
>              imap_search(
>                  $stream,
>                  $criteria,
>                  $options,
>                  $charset
>              );
>          } catch (\Throwable $throwable) {
>              printf(
>                  "%s (%s): %s\n",
>                  $charset,
>                  gettype($charset),
>                  $throwable->getMessage()
>              );
>          }
>      }
> }
> 
> test(...);
> 
> Output:
> 
>   (NULL): imap_search() expects parameter 4 to be string, null given
> 0 (integer): imap_search() expects parameter 4 to be string, int given
> 0 (integer): imap_search() expects parameter 4 to be string, int given

I add

$ php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
     with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
     with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans

[toc] | [prev] | [next] | [standalone]


#18300

From"J.O. Aho" <user@example.net>
Date2020-07-14 14:46 +0200
Message-ID<hn5nq1Fp922U1@mid.individual.net>
In reply to#18298
On 14/07/2020 12.07, alex wrote:
> What is?
> 
> I did some tests with null, NIL and 0, but I was unable to reach a 
> conclusion.
> 
>             imap_search( >                $stream,
>                $criteria,
>                $options,
>                $charset
>            ); 


> Output:
> 
>   (NULL): imap_search() expects parameter 4 to be string, null given
> 0 (integer): imap_search() expects parameter 4 to be string, int given
> 0 (integer): imap_search() expects parameter 4 to be string, int given

IMHO the error does tells quite well what the function expects, a 
string, for example 'UTF-8'. If you don't want to select a charset, then 
don't set one, example: imap_search($stream, $criteria, $options);

Both options and charset are optional, read more at
https://www.php.net/manual/en/function.imap-search.php

-- 

  //Aho



[toc] | [prev] | [next] | [standalone]


#18301

Fromalex <1j9448a02@lnx159sneakemail.com.invalid>
Date2020-07-14 16:05 +0200
Message-ID<reke3t$1733$1@gioia.aioe.org>
In reply to#18300
Il 14/07/20 14:46, J.O. Aho ha scritto:
>>
> 
> IMHO the error does tells quite well what the function expects, a 
> string, for example 'UTF-8'. If you don't want to select a charset, then 
> don't set one, example: imap_search($stream, $criteria, $options);
> 
> Both options and charset are optional, read more at
> https://www.php.net/manual/en/function.imap-search.php

Thanks :)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web