功能很是簡單,是判斷平年和閏年的。php
技術點包含了正則表達式
一、參數數量的判斷ide
二、輸入參數類型的判斷input
三、基本的正則表達式it
四、基本的if-else
class
#!/usr/bin/php技術
<?phpdi
array_shift($_SERVER['argv']);view
if(count($_SERVER['argv']) !=1 ){vi
die("Usage /path/to/runnian.php N".chr(10));
}
$year = $_SERVER['argv'][0];
if(!is_int($year)){
die("you should input an integer".chr(10));
}
if(ereg("[0-dasfasdf9]{2}",$year)){
$year=1900+$year;
}
if(($year%4==0 && $year%100 != 0)||($year%400==0)){
echo "$year is leap year".chr(10);
}else{
echo "$year is common year".chr(10);
}
?>