Erreur: Deprecated: str_replace()
Résolu/FerméLaChaux78 Messages postés 583 Date d'inscription lundi 25 juillet 2016 Statut Membre Dernière intervention 14 janvier 2025 - 22 déc. 2022 à 21:51
- Deprecated: str_replace(): passing null to parameter #3 ($subject) of type array|string is deprecated
- Erreur 0x80070643 - Accueil - Windows
- Erreur 0x80070643 Windows 10 : comment résoudre le problème de la mise à jour KB5001716 - Accueil - Windows
- Erreur 1001 outlook - Accueil - Bureautique
- Instagram une erreur s'est produite ✓ - Forum Instagram
- Erreur 4201 ✓ - Forum Réseaux sociaux
6 réponses
21 déc. 2022 à 20:26
Bonjour,
Tu dis ne pas parvenir à régler ce souci.... Qu'as-tu donc essayé ?
À noter, que le message, est plutôt assez explicite....
Es-tu certain que ta variable contient quelque chose ?
Pourrais-tu nous le montrer en en faisant un var_dump ?
21 déc. 2022 à 23:30
Bonjour suite au var_dump voilà ce qu'il en retourne.
C:\wamp64\www\partitions\fonctions\arborescence.php:30:string '' (length=0) C:\wamp64\www\partitions\fonctions\arborescence.php:30:string '1' (length=1)
Non en fait j'ai regardé sur le net pour essayé de comprendre cette erreur afin de la corriger mais en vain.
Je vous remercie.
21 déc. 2022 à 23:44
Tu regardes bien le contenu de la variable $combinaisonArbre
Avant l'instruction qui te pose problème ?
Pourrais-tu nous montrer l'intégralité du code et pas juste cette ligne...
Quoi qu'il en soit, ce message d'avertissement t'indique que ta variable est vide...
22 déc. 2022 à 08:59
Bonjour zut j'ai refait fait un var_dump avant l'instruction de la variable $combinaisonArbre.
Merci
C:\wamp64\www\partitions\fonctions\arborescence.php:2:null
<?php require_once ( "ext2icone.php" ) ; function arborescence ( $chemin, $listeDossiersFichiers, $organisation = null, $rang = 0, $combinaisonArbre = null ) { $dossiers = array () ; $fichiers = array () ; //récupération des tableaux contenant les dossiers et les fichiers //triage des données par ordre alphabétique insensible à la case if ( is_array ( @$listeDossiersFichiers [ $chemin ] [ "dossiers" ] )) { $dossiers = $listeDossiersFichiers [ $chemin ] [ "dossiers" ] ; $dossiers_insensibleCase = array_map ( 'strtolower', $dossiers ) ; array_multisort ( $dossiers_insensibleCase, SORT_ASC, SORT_STRING, $dossiers ) ; } if ( is_array ( @$listeDossiersFichiers [ $chemin ] [ "fichiers" ] )) { $fichiers = $listeDossiersFichiers [ $chemin ] [ "fichiers" ] ; $fichiers_insensibleCase = array_map ( 'strtolower', $fichiers ) ; array_multisort ( $fichiers_insensibleCase, SORT_ASC, SORT_STRING, $fichiers ) ; } //on modifie la combinaison des images de liaison de l'abre pour les sous-branches $combinaisonArbre = str_replace ( 2, 1, $combinaisonArbre ) ; //intersection finale normale => ligne verticale $combinaisonArbre = str_replace ( 3, 1, $combinaisonArbre ) ; //intersection plus => ligne verticale $combinaisonArbre = str_replace ( 5, 0, $combinaisonArbre ) ; //intersection finale normale => rien $combinaisonArbre = str_replace ( 6, 0, $combinaisonArbre ) ; //intersection finale plus => rien if ( $rang != 0 ) { $displayNone = "class=\"displayNone\" " ; } if ( $combinaisonArbre == null ) { //$arborescence = "<div><img src=\"arbo_fichier_pdf/img/icones_ext/folder_music.png\" align=\"absmiddle\" margin=\"0\"/> <b>$chemin</b></div>"; } //organisation par ordre alphabétique //on regroupe les tableaux si on ne souhaite pas séparer les fichiers des dossiers lors de l'affichage //donc on souhaite afficher les données par ordre alphbétique (non sensible à la case) if ( $organisation == null ) { $contenu [ $chemin ] = array_merge ( $dossiers, $fichiers ) ; $contenu_insensibleCase = array_map ( 'strtolower', $contenu [ $chemin ] ) ; array_multisort ( $contenu_insensibleCase, SORT_ASC, SORT_STRING, $contenu [ $chemin ] ) ; $objets = $contenu [ $chemin ] ; $nbObjets = count ( $objets ) ; $i_objet = 1 ; foreach ( $objets as $objet ) { $nom_objet = $objet ; $md5_objet = md5 ( $objet ) ; if ( strrpos ( $objet, "/" )) { $nom_objet = substr ( $objet, ( strrpos ( $objet, "/" ) +1 )) ; } if ( $i_objet == 1 ) { @$arborescence .= "<div id=\"" .md5 ( $chemin ) ."\" $displayNone>" ; } if ( is_file ( $objet )) { $icone_ext = ext2icone ( $nom_objet ) ; $icone_fichier = "<img src=\"".$icone_ext."\" align=\"absmiddle\" margin=\"0\"/> "; //affiche les icônes des fichiers if ( $i_objet == $nbObjets ) { $combinaisonActuelle = 5 ; } else { $combinaisonActuelle = 2 ; } $combinaison = $combinaisonArbre.$combinaisonActuelle ; $liaisonArbre = liaisonArbre ( $combinaison, $md5_objet ) ; $arborescence .= "<div>".$liaisonArbre.$icone_fichier."<a href=\"$objet\" target=\"_blank\">".$nom_objet."</a></div>"; //affiche le nom des fichiers => $nom_objet = nom des fichiers } else { $icone_dossier = "<img src=\"img/icones_ext/close.png\" align=\"absmiddle\" margin=\"0\"/> "; //affiche les icônes des dossiers if ( $i_objet == $nbObjets ) { if ( count ( @$listeDossiersFichiers [ $objet ] [ "dossiers" ] ) >0 || count ( @$listeDossiersFichiers [ $objet ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 6 ; } else { $combinaisonActuelle = 5 ; } } else { if ( count ( @$listeDossiersFichiers [ $objet ] [ "dossiers" ] ) >0 || count ( @$listeDossiersFichiers [ $objet ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 3 ; } else { $combinaisonActuelle = 2 ; } } $combinaison = $combinaisonArbre.$combinaisonActuelle ; $liaisonArbre = liaisonArbre ( $combinaison, $md5_objet ) ; $arborescence .= "<div><span class=\"pointer\" onclick=\"enrouleDeroule_arbre('$md5_objet','$combinaisonActuelle');\">".$liaisonArbre."</span>".$icone_dossier.$nom_objet."</div>" ; $arborescence .= arborescence ( $objet, $listeDossiersFichiers, $organisation, $rang +1, $combinaison ) ; } if ( $i_objet == $nbObjets ) { $arborescence .= "</div>" ; } $i_objet++ ; } } //organisation par ordre fichiers/dossiers ou dossiers/fichiers elseif ( $organisation == "FICHIERS_DOSSIERS" || $organisation == "DOSSIERS_FICHIERS" ) { //nombre de dossiers et fichiers //$nbDossiers = count ( $dossiers ) ; //$nbFichiers = count ( $fichiers ) ; //gestion des fichiers $i_fichier = 1 ; foreach ( $fichiers as $fichier ) { $nom_fichier = $fichier ; $md5_fichier = md5 ( $fichier ) ; if ( strrpos ( $fichier, "/" )) { $nom_fichier = substr ( $fichier, ( strrpos ( $fichier, "/" ) +1 )) ; } if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_fichier == $nbFichiers && $nbDossiers == 0 ) { $combinaisonActuelle = 5 ; } else { $combinaisonActuelle = 2 ; } } else { if ( $i_fichier == $nbFichiers ) { $combinaisonActuelle = 5 ; } else { $combinaisonActuelle = 2 ; } } $combinaison = $combinaisonArbre.$combinaisonActuelle ; $liaisonArbre = liaisonArbre ( $combinaison, $md5_fichier ) ; $icone_ext = ext2icone ( $nom_fichier ) ; $icone_fichier = "<img src=\"".$icone_ext."\" align=\"absmiddle\" margin=\"0\"/> " ; if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_fichier == 1 ) { $arborescence_fichiers .= "<div id=\"".md5 ( $chemin ) ."\" $displayNone>" ; } } else { if ( $i_fichier == 1 && $nbDossiers == 0 ) { $arborescence_fichiers .= "<div id=\"".md5 ( $chemin ) ."\" $displayNone>" ; } } $arborescence_fichiers .= "<div>".$liaisonArbre.$icone_fichier."<a href=\"$fichier\">".$nom_fichier."</a></div>" ; if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_fichier == $nbFichiers && $nbDossiers == 0 ) { $arborescence_fichiers .= "</div>" ; } } else { if ( $i_fichier == $nbFichiers ) { $arborescence_fichiers .= "</div>" ; } } $i_fichier++ ; } //gestion des dossiers $i_dossier = 1 ; foreach ( $dossiers as $dossier ) { $nom_dossier = $dossier ; $md5_dossier = md5 ( $dossier ) ; if ( strrpos ( $dossier, "/" )) { $nom_dossier = substr ( $dossier, ( strrpos ( $dossier, "/" ) +1 )) ; } if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_dossier == $nbDossiers ) { if ( count ( $listeDossiersFichiers [ $dossier ] [ "dossiers" ] ) >0 || count ( $listeDossiersFichiers [ $dossier ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 6 ; } else { $combinaisonActuelle = 5 ; } } else { if ( count ( $listeDossiersFichiers[$dossier ] [ "dossiers" ] ) >0 || count ( $listeDossiersFichiers [ $dossier ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 3 ; } else { $combinaisonActuelle = 2 ; } } } else { if ( $i_dossier == $nbDossiers && $nbFichiers == 0 ) { if ( count ( $listeDossiersFichiers [ $dossier ] [ "dossiers" ] ) >0 || count ( $listeDossiersFichiers [ $dossier ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 6 ; } else { $combinaisonActuelle = 5 ; } } else { if ( count ( $listeDossiersFichiers [ $dossier ] [ "dossiers" ] ) >0 || count ( $listeDossiersFichiers [ $dossier ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 3 ; } else { $combinaisonActuelle = 2 ; } } } $combinaison = $combinaisonArbre.$combinaisonActuelle ; $liaisonArbre = liaisonArbre ( $combinaison, $md5_dossier ) ; $icone_dossier = "<img src=\"img/icones_ext/dossier.png\" align=\"absmiddle\" margin=\"0\"/> " ; if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_dossier == 1 && $nbFichiers == 0 ) { $arborescence_dossiers .= "<div id=\"".md5 ( $chemin ) ."\" $displayNone>" ; } } else { if ( $i_dossier == 1 ) { $arborescence_dossiers .= "<div id=\"".md5 ( $chemin ) ."\" $displayNone>" ; } } $arborescence_dossiers .= "<div><span class=\"pointer\" onclick=\"js/enrouleDeroule_arbre('$md5_dossier','$combinaisonActuelle');\">".$liaisonArbre."</span>".$icone_dossier."<a href=\"$dossier\">".$nom_dossier."</a></div>" ; $arborescence_dossiers .= arborescence ( $dossier, $listeDossiersFichiers, $organisation, $rang +1, $combinaison ) ; if ( $organisation == "FICHIERS_DOSSIERS" ) { if ( $i_dossier == $nbDossiers ) { $arborescence_dossiers .= "</div>" ; } } else { if ( $i_dossier == $nbDossiers && $nbFichiers == 0 ) { $arborescence_dossiers .= "</div>" ; } } $i_dossier++ ; } //sortir les données dans l'ordre souhaité //fichiers puis dossiers if ( $organisation == "FICHIERS_DOSSIERS" ) { $arborescence = $arborescence.$arborescence_fichiers.$arborescence_dossiers ; } //dossiers puis fichiers else { $arborescence = $arborescence.$arborescence_dossiers.$arborescence_fichiers ; } } return @$arborescence ; } ?>
22 déc. 2022 à 10:31
As tu compris que le soucis est que ta variable est null et qu'elle ne le devrait pas as ?
Il faut donc voir d'où elle provient pour corriger le souci
22 déc. 2022 à 16:01
Bonjour oui je regarde merci.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question22 déc. 2022 à 17:40
Bonjour c'est le bin's...
En fait j'avais 3 erreur sur la même page que je n'avais pas vu. Donc la première est résolu j'ai initialisé cette variable.
voici mes 2 autres erreurs.
Merci pour votre aide.
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in C:\wamp64\www\partitions\fonctions\arborescence.php on line 86 TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in C:\wamp64\www\partitions\fonctions\arborescence.php on line 86
22 déc. 2022 à 19:10
Et bien ?
Le message d'erreur est plutôt clair non ?
22 déc. 2022 à 19:47
//Code if ( count ( $listeDossiersFichiers [ $objet ] [ "dossiers" ] ) >0 || count ( $listeDossiersFichiers [ $objet ] [ "fichiers" ] ) >0 ) { $combinaisonActuelle = 3 ; } // A remplacer par : if ( !empty($listeDossiersFichiers[ $objet ][ "dossiers" ]) || !empty($listeDossiersFichiers[ $objet ][ "fichiers" ])0 ) { $combinaisonActuelle = 3 ; }
22 déc. 2022 à 21:51
Bonjour Un très grand merci pour votre aide. Tout fonctionne sans aucune erreur. Cordialement.