PHP Handbuch
Zurück | Anhang K. List of Available Filters | Nach vorne

# Conversion Filters

Like the string.* filters, the convert.* filters perform actions similar to their names. The convert filters were added with `PHP 5.0.0`. For more information on a given filter, refer to the manual page for the corresponding function.

`convert.base64-encode` and `convert.base64-decode` Use of these filters are equivalent to processing all stream data through the base64_encode() and base64_decode() functions respectively. `convert.base64-encode` supports parameters given as an associative array. If `line-length` is given, the base64 output will be split into chunks of `line-length` characters each. If `line-break-chars` is given, each chunk will be delimited by the characters given. These parameters give the same effect as using base64_encode() with chunk_split().

Beispiel K-5. convert.base64-encode & convert.base64-decode
`<?php $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'convert.base64-encode'); fwrite($fp, "This is a test.\n"); fclose($fp); /* Outputs: VGhpcyBpcyBhIHRlc3QuCg== */ $param = array('line-length' => 8, 'line-break-chars' => "\r\n"); $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE, $param); fwrite($fp, "This is a test.\n"); fclose($fp); /* Outputs: VGhpcyBp : cyBhIHRl : c3QuCg== */ $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'convert.base64-decode'); fwrite($fp, "VGhpcyBpcyBhIHRlc3QuCg=="); fclose($fp); /* Outputs: This is a test. */ ?>`

`convert.quoted-printable-encode` and `convert.quoted-printable-decode` Use of the decode version of this filter is equivalent to processing all stream data through the quoted_printable_decode() functions. There is no function equivalent to `convert.quoted-printable-encode`. `convert.quoted-printable-encode` supports parameters given as an associative array. In addition to the parameters supported by `convert.base64-encode`, `convert.quoted-printable-encode` also supports boolean arguments `binary` and `force-encode-first`. `convert.base64-decode` only supports the `line-break-chars` parameter as a type-hint for striping from the encoded payload.

Beispiel K-6. convert.quoted-printable-encode & convert.quoted-printable-decode
`<?php $fp = fopen('php://output', 'w'); stream_filter_append($fp, 'convert.quoted-printable-encode'); fwrite($fp, "This is a test.\n"); /* Outputs: =This is a test.=0A */ ?>`

Zurück | Zum Anfang | Nach vorne
List of Available Filters | Nach oben | Compression Filters