本文整理汇总了PHP中Zend_Validate_Hostname::setValidateIdn方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Hostname::setValidateIdn方法的具体用法?PHP Zend_Validate_Hostname::setValidateIdn怎么用?PHP Zend_Validate_Hostname::setValidateIdn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Validate_Hostname
的用法示例。
在下文中一共展示了Zend_Validate_Hostname::setValidateIdn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRessourceIDN
/**
* Ensure the IDN check works on ressource files as expected
*
*/
public function testRessourceIDN()
{
$validator = new Zend_Validate_Hostname();
// Check IDN matching
$valuesExpected = array(array(true, array('bürger.com', 'hãllo.com', 'hållo.com')), array(true, array('bÜrger.com', 'hÃllo.com', 'hÅllo.com')), array(false, array('hãllo.lt', 'bürger.lt', 'hãllo.lt')));
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
// Check no IDN matching
$validator->setValidateIdn(false);
$valuesExpected = array(array(false, array('bürger.com', 'hãllo.com', 'hållo.com')));
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
// Check setting no IDN matching via constructor
unset($validator);
$validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, false);
$valuesExpected = array(array(false, array('bürger.com', 'hãllo.com', 'hållo.com')));
foreach ($valuesExpected as $element) {
foreach ($element[1] as $input) {
$this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()) . $input);
}
}
}
示例2:
</head>
<body>
<h1>Validate_Hostname POST test</h1>
<p>Please use this form to test UTF-8 hostnames. A list of supported Top-Level Domains exists in
<tt>Zend_Validate_Hostname</tt> in the <tt>$_registeredTlds</tt> class property. You can enable/disable IDN support by changing the radio button below.</p>
<p>Some example valid IDN domains to test include: <em>bürger.de, hãllo.de, hållo.se, bÜrger.de, hÃllo.de, hÅllo.se, höhö.ch</em></p>
<p>Some example invalid IDN domains to test include: <em>hãllo.se, bürger.com, hãllo.uk</em></p>
<?php
if ($_POST['action'] === 'validate') {
require_once 'Zend/Validate/Hostname.php';
$characters = strip_tags($_POST['chars']);
$validator = new Zend_Validate_Hostname();
$idn = true;
if ($_POST['idn'] === "no") {
$validator->setValidateIdn(false);
$idn = false;
}
?>
<h2>Entered characters: <?php
echo $characters;
?>
</h2>
<p><?php
echo $idn ? 'IDN supported' : 'IDN not supported';
?>
</p>
<p>Testing for match in Zend_Validate_Hostname: