2012-03-19 5 views
1

저는 PHP 여행을 시작하면서 간단한 달력을 만드는 방법에 대한 자습서를 작성했습니다. Codepad에서 구문 오류가 발생하여 수정 사항을 찾을 수 없습니다. 나는 그것이 내가 보지 않고있는 것이 단순한 것이라고 확신한다. 죄송합니다. 메모에 대해 가능한 한 주석을 달아서 길을 잃지 않았습니다.PHP 초보자 ... 간단한 PHP 구문 오류

오류 :

Parse error: syntax error, unexpected ',' on line 10. (the $day=('d', $date) declaration) 

코드 : 사전에

<?php 

// current date variable 

$date = time(); 


//day, month and year variables 

$day = ('d', $date); 
$month = ('m', $date); 
$year = ('Y', $date); 


// first day of the month 

$monthfirstday = mktime(0,0,0,$month, 1, $year); 


// get the name of the month 

$monthtitle = ('F', $monthfirstday); 


// first day of the week 

$weekday = ('D', $monthfirstday); 


// identify the days of the week 

switch ($weekday) { 
    case"Sun": $blank=0; 
    break; 
    case"Mon": $blank=1; 
    break; 
    case"Tue": $blank=2; 
    break; 
    case"Wed": $blank=3; 
    break; 
    case"Thu": $blank=4; 
    break; 
    case"Fri": $blank=5; 
    break; 
    case"Sat": $blank=6; 
    break; 
} 


// number of days in the month 

$daysinmonth = cal_days_in_month(0, $month, $year); 


// include the html 

echo "<div id='calendar-wrap'>"; 
echo "<table border=6 width=394><tr><th colspan=60> $monthtitle $year</th></tr>"; 
echo " 
    <tr> 
     \n\t\t<td width=62>SUN</td> 
     \n\t\t<td width=62>MON</td> 
     \n\t\t<td width=62>TUES</td> 
     \n\t\t<td width=62>WEDS</td> 
     \n\t\t<td width=62>THURS</td> 
     \n\t\t<td width=62>FRI</td> 
     \n\t\t<td width=62>SAT</td> 
     </tr> 
"; 


$daycount = 1; 

echo "<tr>"; 


// dealing with the days of the month 

$blank > 0 
{ 
echo "<td></td>"; 
$blank = $blank-1; 
$daycount++; 
}   


// set the day number to 1 

$daynumber = 1; 


// count the days of the month 

while 
($daynumber <= $daysinmonth) 
{ 
echo "<td> $daynumber </td>"; 


// increase the day count until the month ends 

$daynumber++; 
$daycount++; 


// add a new row every 7 days 

if ($daycount > 7) 
{ 
echo "</tr><tr>"; 
$daycount = 1; 
} 
} 

// fill in blank days if necessary 

while 
($daycount > 1 && $daycount <= 7) 
{ 
echo "<td> </td>"; 
$daycount++; 
} 

echo "</tr></table></div>"; 

?> 

감사합니다,

마이크

+7

'$ 일 = 날짜 ('d ', $ 날짜);' – scibuff

답변

6

귀하의 기능이 없습니다!

다음
$day = date('d', $date); 
+0

오 남자 ... * 블러셔 * – TheNally

3

당신이 가서 ...

$day = date('d', $date); 
$month = date('m', $date); 
$year = date('Y', $date); 
1

나는이 작업을 수행하려는 생각 :

$day = date('d', $date); 
0

이것은 오류이다. 함수를 놓친 :)

$day = date('d', $date); 
$month = date('m', $date); 
$year = date('Y', $date);