1--TEST-- 2IDN UTS #46 API error tests 3--EXTENSIONS-- 4intl 5--SKIPIF-- 6<?php 7 if (!defined('INTL_IDNA_VARIANT_UTS46')) 8 die('skip no UTS #46 API'); 9?> 10--FILE-- 11<?php 12ini_set("intl.error_level", E_WARNING); 13echo "=> PHP level errors", "\n"; 14 15echo "bad variant:", "\n"; 16var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46 + 10)); 17 18echo "empty domain:", "\n"; 19var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46)); 20 21echo "with error, but no details arg:", "\n"; 22var_dump(idn_to_ascii("www.fußball.com-", 0, INTL_IDNA_VARIANT_UTS46)); 23 24echo "with error, with details arg:", "\n"; 25var_dump(idn_to_ascii("www.fußball.com-", IDNA_NONTRANSITIONAL_TO_ASCII, 26 INTL_IDNA_VARIANT_UTS46, $foo)); 27var_dump($foo); 28 29echo "with error, with details arg, contextj:", "\n"; 30var_dump(idn_to_ascii( 31 html_entity_decode("www.a‍b.com", 0, "UTF-8"), 32 IDNA_NONTRANSITIONAL_TO_ASCII | IDNA_CHECK_CONTEXTJ, 33 INTL_IDNA_VARIANT_UTS46, $foo)); 34var_dump($foo); 35var_dump($foo["errors"]==IDNA_ERROR_CONTEXTJ); 36 37?> 38--EXPECTF-- 39=> PHP level errors 40bad variant: 41 42Warning: idn_to_ascii(): idn_to_ascii: invalid variant, must be INTL_IDNA_VARIANT_UTS46 in %s on line %d 43bool(false) 44empty domain: 45 46Warning: idn_to_ascii(): idn_to_ascii: empty domain name in %s on line %d 47bool(false) 48with error, but no details arg: 49bool(false) 50with error, with details arg: 51bool(false) 52array(3) { 53 ["result"]=> 54 string(23) "www.xn--fuball-cta.com-" 55 ["isTransitionalDifferent"]=> 56 bool(true) 57 ["errors"]=> 58 int(16) 59} 60with error, with details arg, contextj: 61bool(false) 62array(3) { 63 ["result"]=> 64 string(18) "www.xn--ab-m1t.com" 65 ["isTransitionalDifferent"]=> 66 bool(true) 67 ["errors"]=> 68 int(4096) 69} 70bool(true) 71