Services webmasters
Partenaires
Jeux concours gratuits
 
stream_copy_to_stream
<<<
stream_filter_append stream_filter_prepend
>>>

7.100 Flôts
7 Index des fonctions
 Manuel PHP

Introduction
Filtres de flôts
Contextes de flôts
Installation
Classes Stream
Constantes prédefinies
Erreurs de flôts
Exemples
stream_context_create
stream_context_get_options
stream_context_set_option
stream_context_set_params
stream_copy_to_stream
->stream_filter_append
stream_filter_prepend
stream_filter_register
stream_get_filters
stream_get_line
stream_get_meta_data
stream_get_transports
stream_get_wrappers
stream_register_wrapper
stream_select
stream_set_blocking
stream_set_timeout
stream_set_write_buffer
stream_socket_accept
stream_socket_client
stream_socket_get_name
stream_socket_server
stream_wrapper_register

7.100.14 stream_filter_append()Attache un filtre à un flôt en fin de liste

[ Exemples avec stream_filter_append ]   PHP 4 >= 4.3.0

bool  stream_filter_append ( resource   stream , string   filtername , int   read_write , string   params )

stream_filter_append ajoute le filtre filtername à la liste de filtres attachés au flôt stream . Ce filtre sera ajoutés avec les paramètres spécifiés dans params à la fin de cette liste et sera donc appelé en dernier durant les opérations de flôts. Pour ajouter un filtre au début de la liste, utilisez la fonction stream_filter_prepend .

Par défaut, stream_filter_prepend va ajouter le filtre à la liste de filtre de lecture si le fichier a été ouvert en mode lecture ( r et/ou + ). Le filtre sera aussi attaché à la liste des filtres de lecture si le fichier a été ouvert en mode lecture ( w , a et/ou + ). STREAM_FILTER_READ , STREAM_FILTER_WRITE , et/ou STREAM_FILTER_ALL peuvent aussi être utilisées dans le paramètre read_write pour contrôler ce comportement. Voyez la fonction stream_filter_append pour un exemple de l'utilisation de ce paramètre.

Contrôler l'application des filtres

<?php
/* Open a test file for reading and writting */
$fp = fopen("test.txt","rw");

/* Apply the ROT13 filter to the
* write filter chain, but not the
* read filter chain */
stream_filter_append($fp, "string.rot13", STREAM_FILTER_WRITE);

/* Write a simple string to the file
* it will be ROT13 transformed on the
* way out */
fwrite($fp, "This is a test\n");

/* Back up to the beginning of the file */
rewind($fp);

/* Read the contents of the file back out.
* Had the filter been applied to the
* read filter chain as well, we would see
* the text ROT13ed back to its original state */
fpassthru($fp);

fclose($fp);

/* Expected Output
   ---------------

Guvf vf n grfg

*/
?>

Note
Quand utiliser des filtres personnalisés

stream_register_filter doit être appelé avant stream_filter_prepend pour enregistrer le filtre sous le nom de filtername .

Voir aussi stream_register_filter et stream_filter_prepend

<< stream_filter_append >>
stream_copy_to_stream Flôts stream_filter_prepend
Services webmasters
Les manuels
 
CoursPHP.com - Reproduction interdite -