本文整理汇总了PHP中utf8_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_encode函数的具体用法?PHP utf8_encode怎么用?PHP utf8_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_request
/**
* Do CURL request with authorization
*/
private function do_request($resource, $method, $input)
{
$called_url = $this->base_url . "/" . $resource;
$ch = curl_init($called_url);
$c_date_time = date("r");
$md5_content = "";
if ($input != "") {
$md5_content = md5($input);
}
$content_type = "application/json";
$sign_string = $method . "\n" . $md5_content . "\n" . $content_type . "\n" . $c_date_time . "\n" . $called_url;
$time_header = 'X-mailin-date:' . $c_date_time;
$auth_header = 'Authorization:' . $this->access_key . ":" . base64_encode(hash_hmac('sha1', utf8_encode($sign_string), $this->secret_key));
$content_header = "Content-Type:application/json";
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// Windows only over-ride
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array($time_header, $auth_header, $content_header));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input);
$data = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch) . '\\n';
}
curl_close($ch);
return json_decode($data, true);
}
示例2: save_xml_file
function save_xml_file($filename, $xml_file)
{
global $app_strings;
$handle = fopen($filename, 'w');
//fwrite($handle,iconv("GBK","UTF-8",$xml_file));
if (!$handle) {
return;
}
// Write $somecontent to our opened file.)
if ($app_strings['LBL_CHARSET'] == "GBK") {
if (function_exists('iconv')) {
$xml_file = iconv_ec("GB2312", "UTF-8", $xml_file);
} else {
$chs = new Chinese("GBK", "UTF8", trim($xml_file));
$xml_file = $chs->ConvertIT();
}
if (fwrite($handle, $xml_file) === FALSE) {
return false;
}
} else {
if ($app_strings['LBL_CHARSET'] != "UTF-8") {
//$xml_file = iconv("ISO-8859-1","UTF-8",$xml_file);
if (fwrite($handle, utf8_encode($xml_file)) === FALSE) {
return false;
}
} else {
if (fwrite($handle, $xml_file) === FALSE) {
return false;
}
}
}
fclose($handle);
return true;
}
示例3: ListField
function ListField($field)
{
if ($field !== null && $field !== '' && $field !== 'undefined') {
$fieldtrue = explode('|', $field);
return utf8_encode($fieldtrue[1]);
}
}
示例4: server
function server()
{
list($dr, $nod) = split_right('/', $_GET['table'], 1);
$main = msql_read($dr, $nod, '');
//p($main);
if ($main) {
$dscrp = flux_xml($main);
}
$host = $_SERVER['HTTP_HOST'];
//$dscrp=str_replace('users/','http://'.$host.'/users/',$dscrp);
//$dscrp=str_replace('img/','http://'.$host.'/img/',$dscrp);
$xml = '<' . '?xml version="1.0" encoding="utf-8" ?' . '>' . "\n";
//iso-8859-1//
$xml .= '<rss version="2.0">' . "\n";
$xml .= '<channel>' . "\n";
$xml .= '<title>http://' . $host . '/msql/' . $_GET['table'] . '</title>' . "\n";
$xml .= '<link>http://' . $host . '/</link>' . "\n";
$xml .= '<description>' . count($main) . ' entries</description>' . "\n";
$xml .= $dscrp;
$xml .= '</channel>' . "\n";
$xml .= '</rss>' . "\n";
//$xml.='</xml>'."\n";
if ($_GET['bz2']) {
return bzcompress($xml);
}
if ($_GET["b64"]) {
return base64_encode($xml);
}
return utf8_encode($xml);
}
示例5: isoConvert
/**
* Converts ISO-8859-1 strings to UTF-8 if necessary.
*
* @param string $string text which is to check
* @return string with utf-8 encoding
*/
public function isoConvert($string)
{
if (!preg_match('/\\S/u', $string)) {
$string = utf8_encode($string);
}
return $string;
}
示例6: convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value !== null) {
$value = utf8_encode($value);
}
return parent::convertToPHPValue($value, $platform);
}
示例7: set_user_config
public function set_user_config($username, $password, $fields)
{
$req = array();
$req['auth']['rw'] = 1;
// request read-write mode
$req['user']['username'] = utf8_encode($username);
$req['user']['password'] = utf8_encode($password);
// modify values in place
foreach ($fields as &$value) {
$value = utf8_encode($value);
}
$req['mailbox']['update'][$username] = $fields;
$arr = $this->get_url($this->build_url($req));
$res = $this->decrypt($arr[0]);
if (empty($res)) {
return array(FALSE, 'Decode error');
}
if ($this->debug) {
$debug_str = '';
$debug_str .= print_r($req, TRUE);
$debug_str .= print_r($arr, TRUE);
$debug_str .= print_r($res, TRUE);
write_log('vboxadm', $debug_str);
}
if ($res['action'] == 'ok') {
return array(TRUE, $res['mailbox']['update'][$username]['msgs']);
} else {
return array(FALSE, $res['error']['str']);
}
}
示例8: mensagensRecebidas
public function mensagensRecebidas($destinatario)
{
$mensagemController = new MensagemController();
$usuarioController = new UsuarioController();
$mensagem = $mensagemController->listaRecebidos($destinatario);
if (count($mensagem) > 0) {
foreach ($mensagem as $value) {
if ($value->getMsg_lida() === 'n') {
$naolida = 'msg_nao_lida';
} else {
$naolida = '';
}
$usuario = $usuarioController->select($value->getMsg_remetente());
echo '<div id="msg_valores_' . $value->getMsg_id() . '" class="recebido ' . $naolida . ' col1 row msg_valores_' . $value->getMsg_id() . '" style="cursor: pointer">
<p class="msg_check col-md-1"><span class="check-box" id="' . $value->getMsg_id() . '"></span></p>
<div onclick="RecebidasDetalheFuncao(' . utf8_encode($value->getMsg_id()) . ')">
<p class="msg_nome col-md-2">' . utf8_encode($usuario->getUsr_nome()) . '</p>
<p class="msg_assunto col-md-7">' . utf8_encode($value->getMsg_assunto()) . '</p>
<p class="msg_data col-md-2">' . date('d/m/Y', strtotime($value->getMsg_data())) . '</p>
</div>
</div>';
}
} else {
echo '<div class="alert alert-warning" role="alert"><strong>Nenhuma mensagem em sua Caixa de Entrada.</strong></div>';
}
}
示例9: objectToArray
/**
* Converter objetos em array.
*
* @param type $var
* @return type
*/
public static function objectToArray($var)
{
$result = array();
$references = array();
// loop over elements/properties
foreach ($var as $key => $value) {
// recursively convert objects
if (is_object($value) || is_array($value)) {
// but prevent cycles
if (!in_array($value, $references)) {
// Verificar se o valor é nulo. Não adiciona tuplas
// vazias ao json
if (!is_null($value) && !empty($value)) {
$result[$key] = JsonUtil::objectToArray($value);
$references[] = $value;
}
}
} else {
// Verificar se o valor é nulo. Não adiciona tuplas
// vazias ao json
if (!is_null($value) && !empty($value)) {
// simple values are untouched
$result[$key] = utf8_encode($value);
}
}
}
return $result;
}
示例10: encrypt
function encrypt($pure_string, $encryption_key)
{
$iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
return base64_encode($encrypted_string);
}
示例11: ote_accent
function ote_accent($str)
{
$str = str_replace("'", " ", $str);
$str = utf8_decode($str);
$ch = strtr($str, '����������������������������������������������������', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
return utf8_encode($ch);
}
示例12: url
public function url($reference)
{
$timestamp = gmdate('D, d M Y H:i:s T');
$security = base64_encode(hash_hmac('sha256', utf8_encode("{$reference}\n{$timestamp}"), $this->client->api_secret, true));
$data = array('key' => $this->client->api_key, 'timestamp' => $timestamp, 'reference' => $reference, 'security' => $security);
return $this->client->api_endpoint . '/widget?' . http_build_query($data);
}
示例13: sms
public function sms()
{
$funcionalidades = new funcionalidades();
$conn = new conn();
$conn->insert(array('dtCad' => $this->data, 'campanha' => utf8_encode($this->nome), 'palavra_chave' => $this->palavras_chaves, 'descricao' => $this->descricao, 'validadeIni' => $funcionalidades->ChecaVariavel($this->valiadeDe, "data"), 'validadeFim' => $funcionalidades->ChecaVariavel($this->validadeAte, "data"), 'patrocinador' => $this->patrocinador, 'qtdCupons' => $this->qtd, 'contato' => $this->contato, 'mensagem' => $funcionalidades->removeAcentos($this->msg), 'dt_limiteCupom' => $funcionalidades->ChecaVariavel($this->dt_limiteCupom, "data"), 'mensagem_encerrado' => $funcionalidades->removeAcentos($this->mensagem_encerrado), 'status' => 1), "", "campanha_sms");
exit("<script>alert('Campanha cadastrada com sucesso!');document.location.href='painel-index.php';</script>");
}
示例14: __construct
/**
* Construct calendar response
*
* @param Calendar $calendar Calendar
* @param int $status Response status
* @param array $headers Response headers
*/
public function __construct(Calendar $calendar, $status = 200, $headers = array())
{
$this->calendar = $calendar;
$content = utf8_encode($calendar->createCalendar());
$headers = array_merge($this->getDefaultHeaders(), $headers);
parent::__construct($content, $status, $headers);
}
示例15: parseCSV
/**
* Parse a csv file
*
* @return array
*/
public function parseCSV()
{
$finder = new Finder();
$rows = array();
$convert_utf8 = function ($s) {
if (!mb_check_encoding($s, 'UTF-8')) {
$s = utf8_encode($s);
}
return $s;
};
$finder->files()->in($this->path)->name($this->fileName);
foreach ($finder as $file) {
$csv = $file;
}
if (($handle = fopen($csv->getRealPath(), "r")) !== false) {
$i = 0;
while (($data = fgetcsv($handle, null, ";")) !== false) {
$i++;
if ($this->ignoreFirstLine && $i == 1) {
continue;
}
$rows[] = array_map($convert_utf8, $data);
}
fclose($handle);
}
return $rows;
}