- 论坛徽章:
- 1
|
本帖最后由 这个冬天不冷 于 2014-04-11 16:29 编辑
bash版本太多了,php也可以当作脚本写- <?php
- function yi(){
- $path = "/home/syh/";
- for($i=1;$i<=100;$i++){
- mkdir($path . "a" . $i, 0777);
- }
- }
- function er()
- {
- die("太麻烦\n");
- }
- function san()
- {
- $file = "/etc/passwd";
- $fp = fopen($file, "r");
- while(!feof($fp)){
- $tmp = fgets($fp);
- $arr = explode(":", $tmp);
- if(is_array($arr) && isset($arr[0]) && strlen($arr[0])){
- echo "the 1 account is " . $arr[0] ."\n";
- }
- }
- }
- function si(){
- die("太麻烦\n");
- }
- function wu(){
- $stdin = fopen('php://stdin', 'r');
- $nums = fgets($stdin);
- $arr_nums = explode(" ", $nums);
- sort($arr_nums);
- echo $arr_nums[0], "\t", $arr_nums[count($arr_nums)-1], "\n";
- }
- function liu(){
- $stdin = fopen('php://stdin', 'r');
- $num = intval(fgets($stdin));
- if($num<1){
- die("taixiao\n");
- }
- for($i=1; $i<=$num; $i++){
- for($j=1; $j<=$i;$j++){
- echo $j.'×'.$i.'='.$i*$j, "\t";
- }
- echo "\n";
- }
- }
- function qi()
- {
- $stdin = fopen('php://stdin', 'r');
- $date = fgets($stdin);
- $time = strtotime($date);
- $now = time();
- $t = $time - $now;
- if( $t < 0){
- echo "生日已经过了";die();
- }
- echo "你的生日还剩", intval(intval($t)/86400), "天",intval(intval($t)%86400/3600),"个小时";
- }
- //just like this 调用
- qi();
复制代码 @reb00t
我真是闲的无聊了。。。。。 |
|