php没有解析怎么办_后端开发
php没有解析的解决方法是:在配置文件中添加对应的php类型即可。具体方法:1、打开httpd.conf配置文件;2、添加配置【AddType application/x-httpd-php .php】即可。
php中将ascii转字符串的方法:默认当前的php文件环境是【UTF-8】,如果是GBK的话将【mb_convert_encoding】省略即可,代码为【function asciitostr($sacii)】。
php中将ascii转字符串的方法:
php中设置cookie时间的方法是什么_后端开发
php中设置cookie时间的方法是:【setcookie(“cookie_name”,”abcd”,time()+3600);】。setcookie()函数向客户端发送一个HTTP cookie。cookie是由服务器发送到浏览器的变量。
将字符串(支持中文)转为ascii
注意:默认当前的php文件环境是UTF-8,如果是GBK的话mb_convert_encoding可省略。
function strtoascii($str){
$str=mb_convert_encoding($str,'GB2312');
$change_after='';
for($i=0;$i
$temp_str=dechex(ord($str[$i]));
$change_after.=$temp_str[1].$temp_str[0];
}
return strtoupper($change_after);
}//strtoascii
function asciitostr($sacii){
$asc_arr= str_split(strtolower($sacii),2);
$str='';
for($i=0;$i
$str.=chr(hexdec($asc_arr[$i][1].$asc_arr[$i][0]));
}
return mb_convert_encoding($str,'UTF-8','GB2312');
}
相关学习推荐:PHP编程从入门到精通