Tag Archives: PHP

Run Shell command using PHPShell in your shared host

PHP has a shell_exec command: “Execute command via shell and return the complete output as a string ” http://php.net/manual/en/function.shell-exec.php And here is a project: http://phpshell.sourceforge.net/ PHP Shell PHP Shell is a shell wrapped in a PHP script. It’s a tool …

Posted in PHP | Tagged , , | Leave a comment

PHP Utils: 复制/批量移除 数组内元素

1. 将$source内的元素复制到$target数组内 2. 将$target数组内 拥有与 $source相同key的元素移除. /** * 将指定Array内的元素复制到目标Array中, 如果具有相同key, 则会被覆盖. **/ public static function copyArrayItems($source, $target) { foreach($source as $sourceItemKey=>$sourceItemValue) { $target[$sourceItemKey] = $sourceItemValue; } return $target; } /** * 移除$target数组中中带有 $source中元素相同key的元素. * @param $source * @param $target * …

Posted in PHP | Tagged , , | 1 Comment

PHP数学运算: 向上/向下取整及四舍五入

1. ceil 向上取整 2. floor 向下取整 3. round 四舍五入 4.intval 转为整数 实例: $value= 5.1; echo ceil($value); // 6 echo floor($value); // 5 echo round($value); // 5 echo intval($value); // 5

Posted in PHP | Tagged , , , , , , | Leave a comment

XAMPP下修改Apache的Timeout

本以为是在httpd.conf中可直接修改TimeOut, 但未在该文件中发现该参数. 但有很多Include: # Various default settings Include conf/extra/httpd-default.conf 果然, 修改/extra/httpd-default.conf即可.

Posted in PHP | Tagged , , , | Leave a comment

PHP中使用静态方法

定义静态方法: Class EmailUtils { /** 判断给定的字符是否为Email字符. */ public static function isEmailChar($char) { return eregi("[a-zA-Z0-9\.\_\@]", $char); } } //end of class 类内部使用静态方法: self::isEmailChar($str); 类外部使用静态方法: EmailUtils ::isEmailChar($str);

Posted in PHP | Tagged , | Leave a comment