1、删除字符串的第一个字符:
$string='';
foreach($arrayas$key => $value){
$string .= ",$value";
}
$string = substr($string,1);2、定义页面编码格式:
<meta http-equiv=content-type content="text/html; charset=UTF-8">header("Content-type:text/html;charset=utf-8");3、设置运行时间限制和浏览器关闭限制:
set_time_limit(0); ignore_user_abort(true);
4、截取两个字符串中的部份
立即学习“PHP免费学习笔记(深入)”;
functiongetStringMiddlePart($str,$str_begain,$str_end){//请确保$str_begain在$str中的唯一性$temp = explode($str_begain,$str);
if(!isset($temp[1])) returnfalse;
$temp = explode($str_end,$temp[1]);
return$temp[0];
}<script type="text/javascript"> $(function () {
$('pre.prettyprint code').each(function () {
var lines = $(this).text().split('\n').length;
var $numbering = $('<ul/>').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i <= lines; i++) {
$numbering.append($('<li/>').text(i));
};
$numbering.fadeIn(1700);
});
});
</script>以上就介绍了PHP---常用代码,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。











