2012-03-19 8 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

あなたは '$ day = date( 'd'、$ date);' – scibuff

答えて

6

あなたの機能はありません!あなたが行くここ

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

oh man ... * blushing * – 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);