本文整理汇总了PHP中utf8_to_gbk函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_to_gbk函数的具体用法?PHP utf8_to_gbk怎么用?PHP utf8_to_gbk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_to_gbk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* Convert encoding
*
* @param $value
* @param $to
* @param $from
*
* @return string
*/
public static function convert($value, $to, $from)
{
if ($value == null) {
return $value;
}
//有ccode库
$isccode = function_exists('is_gbk');
//专门有处理gbk/utf8转码的扩展,解决一些badcase
if ($to === 'GBK' && ($from === 'UTF-8' || $from === 'UTF8') && $isccode) {
$v = utf8_to_gbk($value, strlen($value), UCONV_INVCHAR_REPLACE);
if ($v !== false) {
return $v;
} else {
Logger::warn("utf8_to_gbk fail str=%s", bin2hex($value));
}
}
if (($to === 'UTF-8' || $to === 'UTF8') && $from === 'GBK' && $isccode) {
$v = gbk_to_utf8($value, strlen($value), UCONV_INVCHAR_REPLACE);
if ($v !== false) {
return $v;
} else {
Logger::warn("gbk_to_utf8 fail str=%s", bin2hex($value));
}
}
//return mb_convert_encoding($value,$to,$from);
//mb_convert会由于字符编码问题出fatal,改成iconv //ignore模式
return iconv($from, $to . '//ignore', $value);
}
示例2: convertfile
function convertfile($in_charset, $out_charset, $str)
{
if (function_exists('mb_convert_encoding')) {
if (empty($in_charset)) {
$encode_arr = array('UTF-8', 'ASCII', 'GBK', 'GB2312', 'BIG5', 'JIS', 'eucjp-win', 'sjis-win', 'EUC-JP');
$encoded = mb_detect_encoding($str, $encode_arr);
if (!empty($encoded)) {
$in_charset = $encoded;
}
}
echo $in_charset;
return mb_convert_encoding($str, $out_charset, $in_charset);
} else {
require_once PATH . 'include/charset.func.php';
$in_charset = strtoupper($in_charset);
$out_charset = strtoupper($out_charset);
if ($in_charset == 'UTF-8' && ($out_charset == 'GBK' || $out_charset == 'GB2312')) {
return utf8_to_gbk($str);
}
if (($in_charset == 'GBK' || $in_charset == 'GB2312') && $out_charset == 'UTF-8') {
return gbk_to_utf8($str);
}
return $str;
}
}
示例3: table
} else {
$usinfo = $db->getone("select * from " . table('members') . " where username = '{$username}' LIMIT 1");
}
if (!empty($usinfo)) {
$db->query("update " . table('members') . " set `weixin_openid`=null,`weixin_nick`='',bindingtime=0 where weixin_openid='" . $fromUsername . "'");
$success = false;
$pwd_hash = $usinfo['pwd_hash'];
$usname = $usinfo['username'];
$pwd = md5(md5($password) . $pwd_hash . $QS_pwdhash);
if ($usinfo['password'] == $pwd) {
$access_token = get_access_token();
$w_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $fromUsername . "&lang=zh_CN";
$w_result = https_request($w_url);
$w_userinfo = json_decode($w_result, true);
$success == true;
$db->query("update " . table('members') . " set `weixin_openid`='" . $fromUsername . "',`weixin_nick`='" . utf8_to_gbk($w_userinfo['nickname']) . "',bindingtime=" . time() . " where uid=" . $usinfo['uid']);
require_once QISHI_ROOT_PATH . 'include/fun_wap.php';
if (wap_user_login($username, $password)) {
if (!empty($_SESSION['url'])) {
header("location:" . $_SESSION['url']);
unset($_SESSION['url']);
die;
}
$smarty->display('m/binding-success.html');
die;
}
} else {
$success = false;
}
if ($success == false) {
$smarty->assign("from", $_POST['from']);
示例4: iconv
function iconv($in_charset, $out_charset, $str)
{
$in_charset = strtoupper($in_charset);
$out_charset = strtoupper($out_charset);
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($str, $out_charset, $in_charset);
} else {
pc_base::load_sys_func('iconv');
$in_charset = strtoupper($in_charset);
$out_charset = strtoupper($out_charset);
if ($in_charset == 'UTF-8' && ($out_charset == 'GBK' || $out_charset == 'GB2312')) {
return utf8_to_gbk($str);
}
if (($in_charset == 'GBK' || $in_charset == 'GB2312') && $out_charset == 'UTF-8') {
return gbk_to_utf8($str);
}
return $str;
}
}
示例5: curl_setopt
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$jsoninfo = json_decode($output, true);
$nickname = iconv("utf-8", "gbk", $jsoninfo["nickname"]);
require_once QISHI_ROOT_PATH . 'include/tpl.inc.php';
$smarty->assign('title', '补充信息 - ' . $_CFG['site_name']);
$smarty->assign('qqurl', "?act=");
$smarty->assign('nickname', $nickname);
$smarty->display('m/bind.html');
}
} elseif ($act == 'reg_save') {
if (empty($_SESSION["openid"])) {
exit("openid is empty");
}
$val['username'] = !empty($_POST['username']) ? trim(utf8_to_gbk($_POST['username'])) : exit("输入用户名");
$val['email'] = !empty($_POST['email']) ? trim($_POST['email']) : exit("输入邮箱");
$val['member_type'] = intval($_POST['member_type']);
$val['password'] = !empty($_POST['password']) ? trim($_POST['password']) : exit("输入密码");
if ($val['password'] != trim($_POST['rpassword'])) {
exit("密码不一致");
}
require_once QISHI_ROOT_PATH . 'include/mysql.class.php';
$db = new mysql($dbhost, $dbuser, $dbpass, $dbname);
unset($dbhost, $dbuser, $dbpass, $dbname);
require_once QISHI_ROOT_PATH . 'include/fun_user.php';
$sql = "select * from " . table("members") . " where username='{$val['username']}' or email='{$val['email']}'";
$row = $db->getall($sql);
if (!empty($row)) {
exit("用户名或邮箱已经存在!");
}
示例6: exit
exit('repeat');
}
$addarr['realname'] = $realname;
$addarr['email'] = $email;
$addarr['mobile'] = $mobile;
$addarr['personal_uid'] = intval($_SESSION['uid']);
$addarr['course_id'] = $course['id'];
$addarr['course_name'] = $course['course_name'];
$addarr['train_id'] = $course['train_id'];
$addarr['train_name'] = $course['trainname'];
$addarr['train_uid'] = $course['uid'];
$addarr['notes'] = $notes;
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$addarr['notes'] = utf8_to_gbk($addarr['notes']);
$addarr['realname'] = utf8_to_gbk($addarr['realname']);
$addarr['mobile'] = utf8_to_gbk($addarr['mobile']);
}
$addarr['apply_addtime'] = time();
$addarr['personal_look'] = 1;
if ($db->inserttable(table('personal_course_apply'), $addarr)) {
$mailconfig = get_cache('mailconfig');
$course['contact'] = $db->getone("select notify from " . table('course_contact') . " where pid='{$course['id']}' LIMIT 1 ");
$sms = get_cache('sms_config');
$trainuser = get_user_info($course['uid']);
if ($mailconfig['set_applycou'] == '1' && $trainuser['email_audit'] == '1' && $course['contact']['notify'] == '1') {
dfopen($_CFG['site_domain'] . $_CFG['site_dir'] . "plus/asyn_mail.php?uid={$_SESSION['uid']}&key=" . asyn_userkey($_SESSION['uid']) . "&act=set_applycou&course_id={$course['id']}&coursename={$course['course_name']}&personal_fullname={$realname}&email={$trainuser['email']}");
}
//sms
if ($sms['open'] == "1" && $sms['set_applycou'] == "1" && $trainuser['mobile_audit'] == "1") {
dfopen($_CFG['site_domain'] . $_CFG['site_dir'] . "plus/asyn_sms.php?uid={$_SESSION['uid']}&key=" . asyn_userkey($_SESSION['uid']) . "&act=set_applycou&course_id={$course['id']}&coursename={$course['course_name']}&personal_fullname={$realname}&mobile={$trainuser['mobile']}");
}
示例7: elseif
</table>
<table width="100%" border="0" cellspacing="5" cellpadding="0" id="error" style="display:none">
<tr>
<td align="center" id="error_msg"></td>
</tr>
</table>
<?php
} elseif ($act == "app_save") {
$setsqlarr['content'] = trim($_POST['content']) ? trim($_POST['content']) : exit("出错了");
$setsqlarr['jobs_id'] = $_POST['jobs_id'] ? intval($_POST['jobs_id']) : exit("出错了");
$setsqlarr['uid'] = intval($_SESSION['uid']);
$setsqlarr['addtime'] = time();
$setsqlarr['report_type'] = intval($_POST['report_type']);
// 投诉类型
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$setsqlarr['content'] = utf8_to_gbk($setsqlarr['content']);
}
$jobsarr = app_get_jobs($setsqlarr['jobs_id']);
if (empty($jobsarr)) {
exit("职位丢失");
} else {
$setsqlarr['jobs_name'] = $jobsarr[0]['jobs_name'];
$setsqlarr['jobs_addtime'] = $jobsarr[0]['addtime'];
$insert_id = $db->inserttable(table('report'), $setsqlarr, 1);
}
if ($insert_id) {
exit("ok");
}
}
示例8: array_map
$jobs = array_map("addslashes", $jobs);
if (check_jobs_apply($jobs['id'], $resumeid, $_SESSION['uid'])) {
continue;
}
$addarr['job_id'] = $jobs['id'];
$addarr['job_name'] = $jobs['jobs_name'];
$addarr['company_id'] = $jobs['company_id'];
$addarr['company_name'] = $jobs['companyname'];
$addarr['company_uid'] = $jobs['uid'];
$addarr['link_name'] = $link_name;
$addarr['link_telephone'] = $link_telephone;
$addarr['remark'] = $remark;
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$addarr['remark'] = utf8_to_gbk($addarr['remark']);
$addarr['link_name'] = utf8_to_gbk($link_name);
$addarr['link_telephone'] = utf8_to_gbk($link_telephone);
}
$addarr['addtime'] = time();
$addarr['uid'] = $_SESSION["uid"];
if ($db->inserttable(table('jobs_reward_clue'), $addarr)) {
write_memberslog($_SESSION['uid'], 2, 1301, $_SESSION['username'], "提交了人才线索,职位:{$jobs['jobs_name']}");
}
$i = $i + 1;
}
if ($i == 0) {
exit("repeat");
} else {
exit("ok");
}
}
function reduce_user_sms($uid)
示例9: receiveText
private function receiveText($object)
{
$this->check_weixin_open($object);
$keyword = trim($object->Content);
$keyword = utf8_to_gbk($keyword);
$keyword = addslashes($keyword);
//自动回复模式
$this->enterSearch($object, $keyword);
if (is_array($this->content)) {
if (isset($this->content[0]['PicUrl'])) {
$result = $this->transmitNews($object, $this->content);
}
} else {
$result = $this->transmitText($object, $this->content);
}
return $result;
}
示例10: check_m_subsite_url
function check_m_subsite_url()
{
global $dbhost, $dbuser, $dbpass, $dbname;
require_once QISHI_ROOT_PATH . 'include/mysql.class.php';
$db = new mysql($dbhost, $dbuser, $dbpass, $dbname);
unset($dbhost, $dbuser, $dbpass, $dbname);
$districtinfo = getIpLookup();
if ($districtinfo === false) {
return false;
}
$province = utf8_to_gbk($districtinfo['province']);
$city = utf8_to_gbk($districtinfo['city']);
$subinfo = $db->getone("select * from " . table('subsite') . " where s_effective=1 and (s_districtname like '%" . $province . "%' or s_districtname like '%" . $city . "%') order by s_id desc limit 1");
if ($subinfo) {
return array('disname' => $subinfo['s_districtname'], 'sitename' => $subinfo['s_sitename'], 'url' => 'http://' . ($subinfo['s_m_domain'] ? $subinfo['s_m_domain'] : $subinfo['s_domain'] . '/m/'));
} else {
return false;
}
}
示例11: trim
}
$setsqlarr['scale'] = trim($_POST['scale']) ? utf8_to_gbk(trim($_POST['scale'])) : exit('您选择公司规模!');
$setsqlarr['scale_cn'] = utf8_to_gbk(trim($_POST['scale_cn']));
$setsqlarr['registered'] = utf8_to_gbk(trim($_POST['registered']));
$setsqlarr['currency'] = utf8_to_gbk(trim($_POST['currency']));
$setsqlarr['address'] = trim($_POST['address']) ? utf8_to_gbk(trim($_POST['address'])) : exit('请填写通讯地址!');
check_word($_CFG['filter'], $setsqlarr['address']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['contact'] = trim($_POST['contact']) ? utf8_to_gbk(trim($_POST['contact'])) : exit('请填写联系人!');
check_word($_CFG['filter'], $setsqlarr['contact']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['telephone'] = trim($_POST['telephone']) ? utf8_to_gbk(trim($_POST['telephone'])) : exit('请填写联系电话!');
check_word($_CFG['filter'], $setsqlarr['telephone']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['email'] = trim($_POST['email']) ? utf8_to_gbk(trim($_POST['email'])) : exit('请填写联系邮箱!');
check_word($_CFG['filter'], $setsqlarr['email']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['website'] = utf8_to_gbk(trim($_POST['website']));
check_word($_CFG['filter'], $setsqlarr['website']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['contents'] = trim($_POST['contents']) ? utf8_to_gbk(trim($_POST['contents'])) : exit('请填写公司简介!');
check_word($_CFG['filter'], $setsqlarr['contents']) ? exit($_CFG['filter_tips']) : '';
$setsqlarr['yellowpages'] = intval($_POST['yellowpages']);
$setsqlarr['contact_show'] = intval($_POST['contact_show']);
$setsqlarr['email_show'] = intval($_POST['email_show']);
$setsqlarr['telephone_show'] = intval($_POST['telephone_show']);
$setsqlarr['address_show'] = intval($_POST['address_show']);
if ($_CFG['company_repeat'] == "0") {
$info = $db->getone("SELECT uid FROM " . table('company_profile') . " WHERE companyname ='{$setsqlarr['companyname']}' AND uid<>'{$_SESSION['uid']}' LIMIT 1");
if (!empty($info)) {
exit("{$setsqlarr['companyname']}已经存在,同公司信息不能重复注册");
}
}
if ($company_profile) {
$_CFG['audit_edit_com'] != "-1" ? $setsqlarr['audit'] = intval($_CFG['audit_edit_com']) : '';
if (updatetable(table('company_profile'), $setsqlarr, " uid='{$uid}'")) {
示例12: get_user_inusername
}
$user = get_user_inusername($usname);
if (defined('UC_API')) {
include_once QISHI_ROOT_PATH . 'uc_client/client.php';
if (uc_user_checkname($usname) === 1 && empty($user)) {
exit("true");
} else {
exit("false");
}
}
empty($user) ? exit("true") : exit("false");
} elseif ($act == 'check_email') {
require_once QISHI_ROOT_PATH . 'include/fun_user.php';
$email = trim($_POST['email']);
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$email = utf8_to_gbk($email);
}
$user = get_user_inemail($email);
if (defined('UC_API')) {
include_once QISHI_ROOT_PATH . 'uc_client/client.php';
if (uc_user_checkemail($email) === 1 && empty($user)) {
exit("true");
} else {
exit("false");
}
}
empty($user) ? exit("true") : exit("false");
} elseif ($act == "top_loginform") {
$contents = '';
if ($_COOKIE['QS']['username'] && $_COOKIE['QS']['password']) {
$contents = '欢迎 <a href="{#$user_url#}" style="color:#339900">{#$username#}</a> 登录! {#$pmscount_a#} <a href="{#$user_url#}">[会员中心]</a> <a href="{#$logout_url#}" >[退出]</a>';
示例13: report_deal
report_deal($_SESSION['uid'], 2, $jobfair['predetermined_point']);
$user_points = get_user_points($_SESSION['uid']);
write_memberslog($_SESSION['uid'], 1, 9001, $_SESSION['username'], "预定了招聘会 《{$jobfair['title']}》 的展位,(-{$jobfair['predetermined_point']}),(剩余:{$user_points})", 1, 1019, "预定招聘会展位", "-{$jobfair['predetermined_point']}", "{$user_points}");
} elseif ($_CFG['operation_mode'] == '2') {
action_user_setmeal($_SESSION['uid'], 'jobsfair_num');
$jobsfair_num = $setmeal['jobsfair_num'] - 1;
write_memberslog($_SESSION['uid'], 1, 9002, $_SESSION['username'], "预定了招聘会 《{$jobfair['title']}》 的展位,剩余参加招聘会{$jobsfair_num}场次", 2, 1019, "预定招聘会展位", "1", "{$jobsfair_num}");
}
write_memberslog($_SESSION['uid'], 1, 1401, $_SESSION['username'], "预定了招聘会 《{$jobfair['title']}》 的展位");
exit("预定成功!");
}
}
} elseif ($act == "salary_search") {
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$_GET['category'] = utf8_to_gbk($_GET['category']);
$_GET['district'] = utf8_to_gbk($_GET['district']);
}
unset($_GET['act']);
$param = array_map("rawurlencode", $_GET);
$url = $_CFG['wap_domain'] . '/salary.php?category=' . $param['category'] . '&district=' . $param['district'];
unset($_GET, $param);
exit($url);
}
//获取职位或者简历的所属UID
function get_uid($aid, $type = 'jobs')
{
global $db;
if ($type == 'resume') {
$table = table('resume');
} else {
$table = table('jobs');
示例14: get_user_inemail
}
$user = get_user_inemail($email);
if (defined('UC_API')) {
include_once QISHI_ROOT_PATH . 'uc_client/client.php';
if (uc_user_checkemail($email) === 1 && empty($user)) {
exit("true");
} else {
exit("false");
}
}
empty($user) ? exit("true") : exit("false");
} elseif ($act == "check_mobile") {
require_once QISHI_ROOT_PATH . 'include/fun_user.php';
$mobile = trim($_POST['mobile']);
if (strcasecmp(QISHI_DBCHARSET, "utf8") != 0) {
$mobile = utf8_to_gbk($mobile);
}
if (!preg_match("/^(13|14|15|18|17)\\d{9}\$/", $mobile)) {
exit("false");
}
$user = get_user_inmobile($mobile);
empty($user) ? exit("true") : exit("false");
} elseif ($act == "top_loginform") {
$block = isset($_GET['block']) ? iconv('utf-8', QISHI_CHARSET, $_GET['block']) : '';
$contents = '';
if ($_COOKIE['QS']['username'] && $_COOKIE['QS']['password']) {
// $contents='欢迎 <a href="{#$user_url#}" style="color:#339900">{#$username#}</a> 登录! {#$pmscount_a#} <a href="{#$user_url#}" style="color:#0066cc">[会员中心]</a> <a href="{#$logout_url#}" style="color:#0066cc">[退出]</a>';
$contents = '<span class="login-reg"><a href="{#$user_url#}" class="underline">{#$username#}</a> <a href="{#$logout_url#}" class="underline">[退出]</a></span>';
} elseif ($_SESSION['activate_username'] && defined('UC_API')) {
$contents = '<span class="login-reg">您的帐号{#$activate_username#}需激活后才可以使用! <a href="{#$activate_url#}" class="underline">[立即激活]</a></span>';
} else {
示例15: utf8_to_gbk
function utf8_to_gbk($arr)
{
if (empty($arr)) {
return false;
}
if (is_array($arr)) {
foreach ($arr as $key => $value) {
$keyN = mb_convert_encoding($key, 'GBK', 'UTF-8');
if ($keyN != $key) {
unset($arr[$key]);
}
$arr[$keyN] = utf8_to_gbk($value);
}
} else {
if (!empty($arr)) {
$arr = mb_convert_encoding($arr, 'GBK', 'UTF-8');
}
}
return $arr;
}