Author Archive

54点提高PHP编程效率 引入缓存机制提升性能

0、用单引号代替双引号来包含字符串,这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说echo是语言结构,不是真正的函数,故把函数加上了双引号)。

1、如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍。

2、$row[’id’] 的速度是$row[id]的7倍。

3、echo 比 print 快,并且使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接,比如echo $str1,$str2。

4、在执行for循环之前确定最大循环数,不要每循环一次都计算最大值,最好运用foreach代替。 (continue reading…)


Typoscript Auto Copyright

## Copyright Notice [Begin]
      # Automatic year update
      lib.copyright = TEXT
      lib.copyright.data = date:U
      lib.copyright.strftime = %Y
      lib.copyright.wrap = 
      # secondary language copyright notice
      [globalVar = GP:L = 1]
        lib.copyright.wrap = 
      [end]
      ## Copyright Notice [End]

php generate ics

header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:-//Foobar Corporation//NONSGML Foobar//EN\n";
echo "METHOD:REQUEST\n"; // requied by Outlook
echo "BEGIN:VEVENT\n";
echo "UID:".date('Ymd').'T'.date('His')."-".rand()."-example.com\n"; // required by Outlok
echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook
echo "DTSTART:20120227T1833000\n"; 
echo "SUMMARY:TEST\n";
echo "DESCRIPTION: this is just a test\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";

TBE_EDITOR.rawurlencode erroneously adds “=” in wizards

If you use a wizard for a colorpicker or a link in TYPO3 4.4.8 and 4.5.3 (haven’t tested with older versions) and click on the wizard button, the current value of the field is retrieved in the window.open() function using

TBE_EDITOR.rawurlencode(document.editform[‘data[pages][1][tx_testextension_color]_hr’].value,200)
TBE_EDITOR.rawurlencode(document.editform[‘data[pages][1][tx_testextension_internet]_hr’].value,200)
This returns a wrong value, because TBE_EDITOR.rawurlencode always adds a “=” in front:
– If the value is empty, “=” will be returned, resulting in a default value “http://=” in the link wizard.
– If a value is set in the color picker, e.g. “#333666”, the result of TBE_EDITOR.rawurlencode will be “=#333666” in the colorpicker wizard. (continue reading…)


安卓重力感应调整

顺序:
1,进入工厂模式:关机情况下,按住“下音量键”和“电源键”,直到出现长震动,这时放开电源键,按住“下音量键”直到出现工厂模式(见图)
2.进入工厂模式后,会先开始自动测试,这时一直按“上音量键”,直到进入主菜单,选择“Item Test”(见图)这里说明一下,下音量键为调整选项,电源键为确认
3.按“下音量键”到G-sensor Calibration,确定(见图)
4.这时注意,确保将手机放在一个水平面上,然后按“下音量键”到Do Calibration(40),点确认,直到调整完毕。
5.重启手机,看看是不是已经调整好了?


Displaying the current date

You can display the current date in various formats on a web site. This can be implemented by using the PHP function strftime within your TypoScript template record. (continue reading…)


PHP Document 代码注释规范

PHPDocumentor是一个用PHP写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的API文档。老的版本是 phpdoc。 (continue reading…)


PHP由周取日期

根据指定年份和周数,获取这一周的周一(开始日期)和周日(结束日期) (continue reading…)


MySQL数据库23道安全保障

使用mysql,安全问题不能不注意。以下是mysql提示的23个注意事项:
1.如果客户端和服务器端的连接需要跨越并通过不可信任的网络,那么就需要使用ssh隧道来加密该连接的通信。
2.用set password语句来修改用户的密码,三个步骤,先“mysql -u root”登陆数据库系统,然后“mysql> update mysql.user set password=password(‘newpwd’)”,最后执行“flush privileges”就可以了。 (continue reading…)


Converting transparent PNG to Jpeg

ImageMagick 6.3.2 with the MagickWand-API and I had troubles to convert and resize a partially transparent png to an jpg-file.
I tried the command line tools and the same things happend.

convert png.png png.jpg
–> a jpg-file is created and the transparent area is white

convert png.png -resize 500×400 png_small.jpg
–> a jpg-file in the right dimension is generated and the transparent area is black

What settings do i have to set if i want transparent areas always to be white?
(continue reading…)


Copyright © 1996-2010 Add Lives. All rights reserved.
iDream theme by Templates Next | Powered by WordPress