本文整理汇总了PHP中Net_IDNA2::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IDNA2::getInstance方法的具体用法?PHP Net_IDNA2::getInstance怎么用?PHP Net_IDNA2::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_IDNA2
的用法示例。
在下文中一共展示了Net_IDNA2::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
// Platform's core initialization.
require dirname(__FILE__) . '/../config.php';
require $PLATFORMCREATE;
ci()->load->helper('url')->library('template');
header('Content-Type: text/html; charset=UTF-8');
//require 'Net/IDNA2.php';
$idn = Net_IDNA2::getInstance();
if (isset($_REQUEST['encode'])) {
$decoded = isset($_REQUEST['decoded']) ? $_REQUEST['decoded'] : '';
try {
$encoded = $idn->encode($decoded);
} catch (Exception $e) {
/* just swallow */
}
}
if (isset($_REQUEST['decode'])) {
$encoded = isset($_REQUEST['encoded']) ? $_REQUEST['encoded'] : '';
try {
$decoded = $idn->decode($encoded);
} catch (Exception $e) {
/* just swallow */
}
}
if (!isset($encoded)) {
$encoded = '';
}
if (!isset($decoded)) {
$decoded = '';
}
示例2: singleton
/**
* Attempts to return a concrete IDNA instance for either php4 or php5,
* only creating a new instance if no IDNA instance with the same
* parameters currently exists.
*
* @param array $params Set of paramaters
*
* @return object Net_IDNA2
* @access public
*/
function singleton($params = array())
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
$signature = serialize($params);
if (!isset($instances[$signature])) {
$instances[$signature] = Net_IDNA2::getInstance($params);
}
return $instances[$signature];
}