With PHP 5.3 I started to recieve
Fatal error: Only variables can be passed by reference
when trying to call idn_to_ascii with second optional parameter (IDNA_DEFAULT).
Moreover these IDNA_* constants are seem to be undefined in PHP 5.3. + PECL idn 0.0.2
When I tried to uninstall PECL idn and install PECL intl (1.1.1) i recieved this:
/tmp/pear/temp/intl/collator/collator_class.c:92: error: duplicate ‘static’
/tmp/pear/temp/intl/collator/collator_class.c:96: error: duplicate ‘static’
/tmp/pear/temp/intl/collator/collator_class.c:101: error: duplicate ‘static’
/tmp/pear/temp/intl/collator/collator_class.c:107: error: duplicate ‘static’
make: *** [collator/collator_class.lo] Error 1
So probably compiling PHP 5.3. from sources with --enable-intl will help, but it only means that PHP 5.3. intl version differs from the one available at PECL, which isn't good, I think.
I've made my code working again by giving second idn_to_ascii parameter as simple integer variable (with value 0), but something bad is going on here and i will not be surprised if it'll break again after another PHP update...
idn_to_ascii
(PHP 5 >= 5.3.0, PECL intl >= 1.0.2, PECL idn >= 0.1)
idn_to_ascii — Convertie un nom de domaine au format IDNA ASCII
Description
Style procédural
$domain
[, int $options = 0
[, int $variant = INTL_IDNA_VARIANT_2003
[, array &$idna_info
]]] )Cette fonction convertit un nom de domaine Unicode au format IDNA ASCII-compatible.
Liste de paramètres
-
domain -
Domaine à convertir. En PHP 5, il doit être encodé UTF-8.
-
options -
Options de conversion - combinaison de constantes IDNA_*. (sauf les constantes IDNA_ERROR_*).
-
variant -
Soit la constante
INTL_IDNA_VARIANT_2003pour IDNA 2003, soit la constanteINTL_IDNA_VARIANT_UTS46pour UTS #46. -
idna_info -
Ce paramètre ne peut être utilisé que si la cosntante
INTL_IDNA_VARIANT_UTS46a été utilisée dans le paramètrevariant. Dans ce cas, ce sera un tableau avec la clé 'result' contenant le résultat de la transformation, la clé 'isTransitionalDifferent' contenant un booléen indiquant l'utilisation du mécanisme transitionnel UTS #46 ayant altéré ou non le résultat, et la clé 'errors' contenant un int représentant un jeu de bits des constantes d'erreurs IDNA_ERROR_*.
Valeurs de retour
Le nom de domaine encodé au format ASCII-compatible. ou FALSE si une erreur survient
Historique
| Version | Description |
|---|---|
| 5.4.0/PECL 2.0.0b1 |
Ajout du paramètre variant et du paramètre
idna_info ; Support de l'UTS #46.
|
Exemples
Exemple #1 Exemple avec idn_to_ascii()
<?php
echo idn_to_ascii('täst.de');
?>
L'exemple ci-dessus va afficher :
xn--tst-qla.de
