Web 开发

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";
}
}
?>

页面跳转部分写法html,js,php写法

1、html跳转:
< meta http-equiv="refresh" content="5; url=http://www.yong3g.com/" / >

2、js跳转:
window.location.href = "http://www.yong3g.com";

3、php跳转:
1).htaccess
redirect 301 /old.htm http://www.yong3g.com

RewriteEngine On
RewriteRule ^(.*)$ http://www.yong3g.com/ [R=301,L]

2)header
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.yong3g.com/");
exit();
?>

4、asp跳转:
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.yong3g.com/"
Response.End
%>

5、JSP跳转:

Apache上的网站性能优化概要

  1. 设置过期时间cache-control或ExpiresDefault
    1. Apache可设置mod_expires和mod_headers,参考Apache HTTP Server Version 2.2 文档
    2. 设置过期时间可参考http://www.w3.org/qa/2007/07/the_way_of_Web_standards.html
  2. 优化索引的性能,优化文档大小,减少HTTP请求,因为浏览器每次只能处理单个域的3、4个HTTP请求,等先前的加载完之后才加载新的其它部分。

又遇到MYSQL乱码==》乱码处理

最近又遇到MySQL的乱码,从一个数据库导出之后导入另一个数据库出现乱码。现在把处理过程小结一下。
刚开始把mysql的数据库文件拷过来,放到mysql的data目录下,也不知道原来用的什么编码。打开数据库看,原来全是乱码,于是把my.ini配置文件的内容添加了如下内容:
;character-set-server=utf8
;collation-server=utf8_general_ci
default-character-set=utf8

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

防止某个页面被Google收录

防止某个页面被Google收录,只要在页面头上加入如下内容即可:

  • 不允许被索引
  1. <meta name="robots" content="noindex,follow" />不允许所有网站收录
  2. <meta name="googlebot" content="noindex, nofollow" />不允许Google收录
  3. <meta name="msnbot" content="noindex, nofollow" />不允许MSN收录

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的换行替换