php

Poedit的使用

Poedit的使用

1、设置首选项

使Poedit支持Cakephp的*.ctp文件。

打开“文件”菜单,“首选项”,“解析器”,“新建立。”

使用CTP文件的解析器命令:

xgettext --language=PHP --force-po -o %o %C %K %F

没设置好会出现这样的错误:xgettext: warning: file ‘.ctp’ extension ‘ctp’ is unknown; will try C.

2、新建项目

打开“文件”菜单,“新建消息目录文档”,全进入设置对话框,

复数形式可设置为:nplurals=2; plural=n==1?0:1;
源文件编码可不设置,如果设置一定要设置正确,如utf-8。

路径设置为你的源代码路径:

关键字设置为函数名之类的即可,如图:

php执行如下代码,apache崩溃

装的是ApacheFriends XAMPP (Basispaket) version 1.7.1的组件。php执行如下代码,apache崩溃,原因未知。
<?php
function foo($str) {
static $i = 0;
print "$str : $i";
++ $i;
}

register_tick_function ( 'foo', 'count' );

declare ( ticks = 6 ) {
for($i = 0; $i < 20; ++ $i) {
echo "$i";
}
}
?>

WordPress的主题,三千个左右

2400个WordPress主题下载:
Yong3g.com_netps.cn_wpthemes.reup.rar

下载主题的站点
http://themes.wopus.org/

100个优秀的免费 WordPress 主题
http://jandan.net/2008/01/09/100-excellent-free-wordpress-themes.html

WordPress的插件使用-添加自定义社会标签到Sociable中

Adding a site to Sociable(添加自定义社会标签到Sociable中)
具体效果可查看:http://www.yong3g.com/

首先从http://yoast.com/wordpress/sociable/下载插件;
1. 下载16x16的图片到目录sociable/images/directory。
2. 打开 sociable.php。
3. 查找数组$sociable_known_sites。
4. Copy / paste the code for another site (they're in alphabetical order).
5. Change the value of favicon to the name of your image file.

偶用到的CURL函数

代码:
# $url = "http://www.netps.cn";
# $ch = curl_init();
# curl_setopt($ch, CURLOPT_URL, $url);
# curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

1、resource curl_init ( [string url])
The curl_init() will initialize a new session and return a CURL handle for use with the curl_setopt(), curl_exec(), and curl_close() functions. If the optional url parameter is supplied then the CURLOPT_URL option will be set to the value of the parameter. You can manually set this using the curl_setopt() function.

2、bool curl_setopt ( resource ch, string option, mixed value)

偶遇到的php函数

1、function nl2br($str)
功能:Inserts HTML line breaks before all newlines in a string
示例:<?php echo nl2br("foo isn't\n bar"); ?>
结果:\n会被HTML的换行替换

重定向状态代码

重定向可以被串联,老版本的RFC2616规定重定向最多不超过5次,一般使用时不要超过3次。

重定向状态代码
状态代码 描述 实现
300 多个选择  
301 永久转移 .htaccess:
RewriteRule ^foo\.php$ /bar.php [R=301,L]
或PHP(如果只有Location而没301状态,相当于302临时重定向):
header('HTTP/1.1 301 Moved Permanently');
header('Location:http://www.netps.cn/bar.php');

htaccess文件配置说明

RewriteEngine on
功能:打开url_rewriter功能,mod_rewrite

RewriteCond %{HTTP_HOST} !^www\.netps\.cn
RewriteRule ^(.*)$ http://www\.netps\.cn/$1 [R=301,L]
功能:把不是www.netps.cn的域名指向www.netps.cn

RewirteRule参数说明:

RewirteRule 标记 含义 描述
R Redirect 发出一个HTTP重定向
F Forbidden 禁止对URL地址的存取
G Gone 标记URL地址不存在