Month: October 2011
WordPress Upload New Media “HTTP error”
版本是 3.2.1 在原本的服务器上运行无错,移植到新的服务器就有这个问题,大概就是服务器配置的缘故了。 官方上也相关的文章。http://wordpress.org/support/topic/25-imagemedia-uploader-problems 是apache Mod_Security 的缘故。如果你能够修改你服务器的httpd.conf文件的话,删除里面关于mod_security部分就可以了。不过多数wordpress玩家是没有权限修改这个文件的,那就只好修改.htaccess文件了。在.htaccess文件里面加上一行: SecFilterEngine Off SecFilterScanPOST Off 这样就可以关闭 Mod_Security。
PHP数据类型转换
PHP的数据类型转换属于强制转换,允许转换的PHP数据类型有: (int)、(integer):转换成整形 (float)、(double)、(real):转换成浮点型 (string):转换成字符串 (bool)、(boolean):转换成布尔类型 (array):转换成数组 (object):转换成对象 PHP数据类型有三种转换方式: 在要转换的变量之前加上用括号括起来的目标类型 使用3个具体类型的转换函数,intval()、floatval()、strval() 使用通用类型转换函数settype(mixed var,string type) 第一种转换方式: (int) (bool) (float) (string) (array) (object) <?php $num1=3.14; $num2=(int)$num1; var_dump($num1); //输出float(3.14) var_dump($num2); //输出int(3) ?> 第二种转换方式: intval() floatval() strval() <?php $str=”123.9abc”; $int=intval($str); //转换后数值:123 $float=floatval($str); //转换后数值:123.9 $str=strval($float); //转换后字符串:”123.9″ ?> 第三种转换方式: settype(); <?php $num4=12.8; $flg=settype($num4,”int”); var_dump($flg); //输出bool(true) var_dump($num4); //输出int(12) ?> from:http://banu.blog.163.com/blog/static/231464820101122114438674/
WordPress UTF8 中文截取
UTF8 中文截取 其中对字符串预先 __() 处理,可以从 qtranslate 中取出当前语言部分然后进行截取。 function the_excerpt_max_charlength($charlength) { $excerpt = get_the_excerpt(); $charlength++; if (mb_strlen($excerpt) > $charlength) { $subex = mb_substr($excerpt, 0, $charlength – 5); $exwords = explode(‘ ‘, $subex); $excut = – ( mb_strlen($exwords[count($exwords) – 1]) ); if ($excut < 0) { echo mb_substr($subex, 0, $excut); } else { echo $subex; } echo…
WordPress 如何修改密码保护表单的文字说明
This piece of code should do it for you. Place this code in your theme’s functions.php file. You can add customizations to the custom_password_form() function – just don’t use print or echo – the function must return a value.