IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[Tableaux] Notice : Array to string conversion (pourquoi?)


Sujet :

Langage PHP

  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    616
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Luxembourg

    Informations forums :
    Inscription : Mars 2007
    Messages : 616
    Points : 556
    Points
    556
    Par défaut [Tableaux] Notice : Array to string conversion (pourquoi?)
    Bonjour,
    Je ne comprends pas pourquoi j'ai cette erreur, certe le script fonctionne normalement, mais j'aimerais comprendre.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    	function send(){
    		$options = array(
    			CURLOPT_URL => $this->Url,
    			CURLOPT_HEADER =>1,
    			CURLOPT_NOBODY => ($this->method==self::METH_HEAD)?1:0,
    		//	CURLOPT_FOLLOWLOCATION => 1,
    			CURLOPT_RETURNTRANSFER => true,
    		//	CURLOPT_TIMEOUT => 30,
    			CURLOPT_HTTPHEADER => $this->headers
    			);
     
    //		print_r($options);
    		$ch = curl_init(); // create cURL handle (ch)
    		if (!$ch) {
        		die("Couldn't initialize a cURL handle");
    		}	
    		print_r($options);
    		$ret = curl_setopt_array($ch,$options);	// ligne 59
    J'obtiens l'erreur suivante :

    Notice: Array to string conversion in /home/c/m/a/cmako/www/httprequest.php on line 59

    pourtant à la ligne 58 (juste avant) j'affiche le contenu de la variable $options le résultalt est surprenant
    Je fais appel à la forction send() plusieures fois.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    Array
    (
        [10002] => http://www.exist.ru/forms/login.asp?sid=32260?target=top?bt=1?pz=0?rnd=700386544
        [42] => 1
        [44] => 0
        [19913] => 1
        [10023] => Array
            (
                [0] => Accept: */*
                [1] => Referer: http://www.exist.ru/
                [2] => User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
                [3] => Host: www.exist.ru
                [4] => Connection: Keep-Alive
            )
     
    )
    Array
    (
        [10002] => http://www.exist.ru/client.asp
        [42] => 1
        [44] => 0
        [19913] => 1
        [10023] => Array
            (
                [0] => Accept: */*
                [1] => Referer: http://www.exist.ru/forms/login.asp?sid=32260?target=top?bt=1?pz=0?rnd=700386544
                [2] => Accept-Language: ru
                [3] => Content-Type: application/x-www-form-urlencoded
                [4] => User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
                [5] => Host: www.exist.ru
                [6] => Connection: Keep-Alive
                [Cookie] => Array
                    (
                        [existru] => yes
                        [ASPSESSIONIDCADTRADC] => DACHAGGBPHAAAJKBECBPOOHA
                    )
     
            )
     
    )
    <br />
    <b>Notice</b>:  Array to string conversion in <b>/home/c/m/a/cmako/www/httprequest.php</b> on line <b>59</b><br />
    Array
    (
        [10002] => http://www.exist.ru/newguid.aspx?url1=/client.asp_ques_
        [42] => 1
        [44] => 0
        [19913] => 1
        [10023] => Array
            (
                [0] => Accept: */*
                [1] => Referer: http://www.exist.ru/forms/login.asp?sid=32260?target=top?bt=1?pz=0?rnd=700386544
                [2] => Accept-Language: ru
                [3] => Content-Type: application/x-www-form-urlencoded
                [4] => User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
                [5] => Host: www.exist.ru
                [6] => Connection: Keep-Alive
                [Cookie] => Array
                    (
                        [existru] => yes
                        [ASPSESSIONIDCADTRADC] => FACHAGGBNFAJEGJDJFMLDLMB
                        [uname] => serka
                        [phash] => %7BAAF0F9E2%2DB40D%2DDBB9%2D0713%2DF974E8C13BDF%7D
                    )
     
            )
     
    )
    Array
    (
        [10002] => http://www.exist.ru/client.asp?
        [42] => 1
        [44] => 0
        [19913] => 1
        [10023] => Array
            (
                [0] => Accept: */*
                [1] => Referer: http://www.exist.ru/forms/login.asp?sid=32260?target=top?bt=1?pz=0?rnd=700386544
                [2] => Accept-Language: ru
                [3] => Content-Type: application/x-www-form-urlencoded
                [4] => User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
                [5] => Host: www.exist.ru
                [6] => Connection: Keep-Alive
                [Cookie] => Array
                    (
                        [existru] => yes
                        [ASPSESSIONIDCADTRADC] => FACHAGGBNFAJEGJDJFMLDLMB
                        [uname] => serka
                        [phash] => %7BAAF0F9E2%2DB40D%2DDBB9%2D0713%2DF974E8C13BDF%7D
                        [ASP.NET_SessionId] => 4jtov1bfdanpsu554wvrvxri
                        [visitid] => af4abadc-1a7d-49e7-8133-bc2f1e3c2d64
                    )
     
            )
     
    )
    Pour certaines valeurs ça passe, et pour le cas n°2 => erreur.
    Est-ce que quelqu'un aurait une explication ?

  2. #2
    Expert éminent sénior

    Profil pro
    Inscrit en
    Juin 2002
    Messages
    6 152
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2002
    Messages : 6 152
    Points : 17 777
    Points
    17 777
    Par défaut
    A tout hasard ne serait-ce pas le sous-tableau de la clé Cookie qu'il n'aime pas (CURLOPT_COOKIE) ?

  3. #3
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2007
    Messages
    616
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Luxembourg

    Informations forums :
    Inscription : Mars 2007
    Messages : 616
    Points : 556
    Points
    556
    Par défaut
    Citation Envoyé par julp Voir le message
    A tout hasard ne serait-ce pas le sous-tableau de la clé Cookie qu'il n'aime pas (CURLOPT_COOKIE) ?
    C'est ce que je pensais aussi au début, mais les cas 3 et 4 suivants il accepte.
    Alors je ne comprends pas.

Discussions similaires

  1. [PDO] Array to string conversion et calcule d'après un code promotion
    Par Valadone dans le forum PHP & Base de données
    Réponses: 13
    Dernier message: 27/06/2015, 18h30
  2. Tableaux php, array to string
    Par Lekno dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 12
    Dernier message: 10/12/2013, 11h52
  3. Array to string conversion
    Par deathart dans le forum CodeIgniter
    Réponses: 17
    Dernier message: 04/09/2012, 13h08
  4. [MySQL] PB : "Notice: Array to string conversion"
    Par moma586 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 13/07/2012, 09h11
  5. [MySQL] Formulaire erreur Array to string conversion
    Par akamaru dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 19/12/2008, 11h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo