Archive for August, 2009
Apache配置多虚拟主机的那点事啊
配置多个虚拟主机的时候只是显示第一个主机。配置文件: NameVirtualHost *:80 ServerName demo.aaa.com DocumentRoot “C:/wamp/www/aaa” ServerName demo.bbb.com DocumentRoot “C:/wamp/www/bbb” 后来我问了谷歌,解决办法是: 将httpd.conf中的以下两部分注释掉,重启apache。 # DocumentRoot “C:/wamp/www” # # Options Indexes FollowSymLinks # AllowOverride None #
转自PHP手册:比较substr, mb_substr和mb_strcut
I found this function to be extremely useful. Here is a practical example, showing the difference between substr(), mb_substr() and mb_strcut(): <?php mb_internal_encoding(‘UTF-8′); $string = ‘cioèòà’; var_dump( substr($string, 0, 6), mb_substr($string, 0, 6), mb_strcut($string, 0, 6) ); ?> Output: string(6) “cioè?” string(9) “cioèòà” string(5) “cioè” Explanation: $string is long 9 bytes c – 1 byte [...]
var undefined;
今天Rainux同学给我上了一课: var undefined; 小测试,谁知道这行代码的意义?这样写肯定没错的。其实这个写法是从 jQuery 源代码里偷出来的意义在于提高访问 undefined 的速度,并且在 IE 里也可以使用 undefined 这个特殊值。IE 很恶心,有 undefined 值,但是不能用 undefined 访问它,只能用 typeof xxx === ‘undefined’ 来判断所以定义一个变量名为 undefined,不给它赋值,那么它的值是 undefined 了。哈哈,有意思吧。
我的第一个框架
下载 虚拟主机配置 ServerName paydev.taomee.com ServerAdmin symphony@taomee.com DocumentRoot “/var/www/paydev” Options FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} !.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$ RewriteRule ^(.*)$ index.php [QSA,L] ErrorLog “/var/log/apache2/paydev_errors.log” CustomLog “/var/log/apache2/paydev_accesses.log” common
获取参数信息:func_num_args和func_get_args
Examples Example #1 func_get_args() example function foo() { $numargs = func_num_args(); echo “Number of arguments: $numargs\n”; if ($numargs >= 2) { echo “Second argument is: ” . func_get_arg(1) . “\n”; } $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { echo “Argument $i is: ” . $arg_list[$i] . “\n”; } } foo(1, 2, 3); ?> The above example will output: Number of arguments: 3 [...]
PHP 获取当前类名、方法名
__CLASS__ 获取当前类名(在此之前我用get_class – -!) __FUNCTION__ 当前函数名(confirm) __METHOD__ 当前方法名 (bankcard::confirm) 非常好用!
PHP遍历对象
自PHP 5 起,还可能遍历对象。 注: 当 foreach 开始执行时,数组内部的指针会自动指向第一个单元。这意味着不需要在 foreach 循环之前调用 reset()。 注: 除非数组是被引用,foreach 所操作的是指定数组的一个拷贝,而不是该数组本身。因此数组指针不会被 each() 结构改变,对返回的数组单元的修改也不会影响原数组。不过原数组的内部指针的确在处理数组的过程中向前移动了。假定 foreach 循环运行到结束,原数组的内部指针将指向数组的结尾。
Linux下批量修改文件内容的命令
find -type f | grep \.php$ | xargs perl -i -pe s%conf.php%conf/conf.php%g