本文整理汇总了PHP中ArrayUtils::utf8EncodeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::utf8EncodeArray方法的具体用法?PHP ArrayUtils::utf8EncodeArray怎么用?PHP ArrayUtils::utf8EncodeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils::utf8EncodeArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: launch
function launch()
{
// not checked below refer to testing returning results through utf8 encoding. plb 2-6-2015
$valid_json_methods = array('GetSuggestions', 'GetListTitles', 'getOverDriveSummary', 'GetPreferredBranches', 'requestPinReset', 'getCreateListForm', 'getBulkAddToListForm', 'AddList', 'getEmailMyListForm', 'sendMyListEmail', 'setListEntryPositions', 'removeTag', 'saveSearch', 'deleteSavedSearch', 'cancelHold', 'cancelHolds', 'freezeHold', 'thawHold', 'getChangeHoldLocationForm', 'changeHoldLocation', 'getReactivationDateForm', 'renewItem', 'renewAll', 'renewSelectedItems', 'getPinResetForm');
$method = $_GET['method'];
if (in_array($method, $valid_json_methods)) {
header('Content-type: application/json');
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
$result = $this->{$method}();
try {
require_once ROOT_DIR . '/sys/Utils/ArrayUtils.php';
$utf8EncodedValue = ArrayUtils::utf8EncodeArray($result);
$output = json_encode($utf8EncodedValue);
$error = json_last_error();
if ($error != JSON_ERROR_NONE || $output === FALSE) {
if (function_exists('json_last_error_msg')) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error_msg()));
} else {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error()));
}
global $configArray;
if ($configArray['System']['debug']) {
print_r($utf8EncodedValue);
}
}
} catch (Exception $e) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => $e));
global $logger;
$logger->log("Error encoding json data {$e}", PEAR_LOG_ERR);
}
echo $output;
} elseif (in_array($method, array('LoginForm', 'getBulkAddToListForm', 'getPinUpdateForm', 'getCitationFormatsForm'))) {
header('Content-type: text/html');
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
echo $this->{$method}();
} else {
header('Content-type: text/xml');
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
$xml = '<?xml version="1.0" encoding="UTF-8"?' . ">\n" . "<AJAXResponse>\n";
if (is_callable(array($this, $_GET['method']))) {
$xml .= $this->{$_GET}['method']();
} else {
$xml .= '<Error>Invalid Method</Error>';
}
$xml .= '</AJAXResponse>';
echo $xml;
}
}
示例2: launch
/**
* Processes method to determine return type and calls the correct method.
* Should not be called directly.
*
* @see Action::launch()
* @access private
* @author Mark Noble <mnoble@turningleaftech.com>
*/
function launch()
{
//header('Content-type: application/json');
header('Content-type: text/html');
header('Cache-Control: no-cache, must-revalidate');
// HTTP/1.1
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// Date in the past
if (is_callable(array($this, $_GET['method']))) {
try {
$result = $this->{$_GET}['method']();
require_once ROOT_DIR . '/sys/Utils/ArrayUtils.php';
$utf8EncodedValue = ArrayUtils::utf8EncodeArray(array('result' => $result));
$output = json_encode($utf8EncodedValue);
$error = json_last_error();
if ($error != JSON_ERROR_NONE || $output === FALSE) {
if (function_exists('json_last_error_msg')) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error_msg()));
} else {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error()));
}
global $configArray;
if ($configArray['System']['debug']) {
print_r($utf8EncodedValue);
}
}
} catch (Exception $e) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => $e));
global $logger;
$logger->log("Error encoding json data {$e}", PEAR_LOG_ERR);
}
} else {
$output = json_encode(array('error' => 'invalid_method'));
}
echo $output;
}
示例3: json_utf8_encode
function json_utf8_encode($result)
{
// TODO: add to other ajax.php or make part of a ajax base class
try {
require_once ROOT_DIR . '/sys/Utils/ArrayUtils.php';
$utf8EncodedValue = ArrayUtils::utf8EncodeArray($result);
$output = json_encode($utf8EncodedValue);
$error = json_last_error();
if ($error != JSON_ERROR_NONE || $output === FALSE) {
if (function_exists('json_last_error_msg')) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error_msg()));
} else {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => json_last_error()));
}
global $configArray;
if ($configArray['System']['debug']) {
print_r($utf8EncodedValue);
}
}
} catch (Exception $e) {
$output = json_encode(array('error' => 'error_encoding_data', 'message' => $e));
global $logger;
$logger->log("Error encoding json data {$e}", PEAR_LOG_ERR);
}
return $output;
}