CKTIS / PHP
rawurlencode()
Codifica i byte di un componente URL secondo RFC 3986.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
rawurlencode(string $string): stringCodifica i byte di un componente URL secondo RFC 3986. Lettere ASCII, cifre e -._~ restano invariati, lo spazio diventa %20. Una barra interna dà %2F, quindi codifica separatamente i segmenti del percorso.
Firma
rawurlencode(string $string): string
Output dell’esempio
a%2Bb%20%2F~
/items/red%2Fblue
Esempi
<?php
$segment = "a+b /~";
echo rawurlencode($segment), PHP_EOL;
echo "/items/", rawurlencode("red/blue");
Risultato
a%2Bb%20%2F~ /items/red%2Fblue