PHP供憐돨휑저잚(CLASS)

2018-09-07 12:05

阅读:531

  릿齡덜쯤 덜쯤흔苟:
<?php
classCalendar{
/*
*錦攣경
*/
var$YEAR,$MONTH,$DAY;
var$WEEK=array(槿퍅휑,槿퍅寧,槿퍅랗,槿퍅힛,槿퍅愷,槿퍅巧,槿퍅짇);
var$_MONTH=array(
01=>寧墩,
02=>랗墩,
03=>힛墩,
04=>愷墩,
05=>巧墩,
06=>짇墩,
07=>펌墩,
08=>검墩,
09=>씽墩,
10=>枷墩,
11=>枷寧墩,
12=>枷랗墩
);
//?阮쳐洹?nbsp;
functionsetYear($year){
$this->YEAR=$year;
}
//삿돤쾨룀
functiongetYear(){
return$this->YEAR;
}
//?阮촬쨌?nbsp;
functionsetMonth($month){
$this->MONTH=$month;
}
//삿돤墩룀
functiongetMonth(){
return$this->MONTH;
}
//?阮쳰廊?nbsp;
functionsetDay($day){
$this->DAY=$day;
}
//삿돤휑퍅
functiongetDay(){
return$this->DAY;
}
//댔丹휑저
functionOUT(){
$this->_env();
$week=$this->getWeek($this->YEAR,$this->MONTH,$this->DAY);//삿돤휑퍅槨槿퍅섯(절흔쏟莖槨2003-07-18,槿퍅巧)
$fweek=$this->getWeek($this->YEAR,$this->MONTH,1);//삿돤늪墩뒤寧莖槨槿퍅섯
echo<divstyle=\margin:0;border:1solidblack;width:300;font:9pt\><formaction=$_SERVER[PHP_SELF]method=\post\style=\margin:0\><selectname=\month\onchange=\this.form.submit();\>;
for($ttmpa=1;$ttmpa<13;$ttmpa++){//댔丹12몸墩
$ttmpb=sprintf(%02d,$ttmpa);
if(strcmp($ttmpb,$this->MONTH)==0){
$select=selectedstyle=\background-color:#c0c0c0\;
}else{
$select=;
}
echo<optionvalue=\.$ttmpb\.$select>.$this->MONTH[$ttmpb].</option>\r\n;
}
echo</select><selectname=\year\onchange=\this.form.submit();\>;//댔丹쾨룀,품빈10쾨
for($ctmpa=$this->YEAR-10;$ctmpa<$this->YEAR+10;$ctmpa++){
if($ctmpa>2037){
break;
}
if($ctmpa<1970){
continue;
}
if(strcmp($ctmpa,$this->YEAR)==0){
$select=selectedstyle=\background-color:#c0c0c0\;
}else{
$select=;
}
echo<optionvalue=\$ctmpa\$select>$ctmpa</option>\r\n;
}
echo</select>
</form>
<tableborder=0align=center>;
for($Tmpa=0;$Tmpa<count($this->WEEK);$Tmpa++){//댔丹槿퍅깃庫
echo<td>.$this->WEEK[$Tmpa];
}
for($Tmpb=1;$Tmpb<=date(t,mktime(0,0,0,$this->MONTH,$this->DAY,$this->YEAR));$Tmpb++){//댔丹杰唐휑퍅
if(strcmp($Tmpb,$this->DAY)==0){//삿돤뎠품휑퍅,隣깃션
$flag=bgcolor=#ff0000;
}else{
$flag=bgcolor=#ffffff;
}
if($Tmpb==1){
echo<tr>;//껸념댔丹
for($Tmpc=0;$Tmpc<$fweek;$Tmpc++){
echo<td>;
}
}
if(strcmp($this->getWeek($this->YEAR,$this->MONTH,$Tmpb),0)==0){
echo<tr><tdalign=center$flag>$Tmpb;
}else{
echo<tdalign=center$flag>$Tmpb;
}
}
echo</table></div>;
}
//삿돤렘랬코寧땍돨휑퍅돨槿퍅鑒
functiongetWeek($year,$month,$day){
$week=date(w,mktime(0,0,0,$month,$day,$year));//삿돤槿퍅
return$week;//삿돤槿퍅
}
function_env(){
if(isset($_POST[month])){//唐寧땍墩
$month=$_POST[month];
}else{
$month=date(m);//칵훰槨굶墩
}
if(isset($_POST[year])){//唐寧쾨
$year=$_POST[year];
}else{
$year=date(Y);//칵훰槨굶쾨
}
$this->setYear($year);
$this->setMonth($month);
$this->setDay(date(d));
}
}
$D=newCalendar;
$D->OUT();
?>


评论


亲,登录后才可以留言!