Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/08/2012, 04:20
roboty
 
Fecha de Ingreso: abril-2011
Mensajes: 867
Antigüedad: 13 años
Puntos: 5
no me funciona ejemplo manual php calendario...

Hola, bueno probe un ejemplo del manual de php, de la libreria calendario para generar uno pasandole los parametros adecuados, pero probe un ejemplo que habia en el manual y no me funciona, lo estoy probando en modo local con windows mi php es 5.3.5 el ejemplo es este:

Código PHP:
Ver original
  1. <?php
  2. # PHP Calendar (version 2.3), written by Keith Devens
  3.  
  4. function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array()){
  5.     $first_of_month = gmmktime(0,0,0,$month,1,$year);
  6.  
  7.     #remember that mktime will automatically correct if invalid dates are entered
  8.    # for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
  9.    # this provides a built in "rounding" feature to generate_calendar()
  10.  
  11.     $day_names = array(); #generate all the day names according to the current locale
  12.    for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
  13.        $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name
  14.  
  15.     list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
  16.     $weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
  17.    $title   = htmlentities(ucfirst($month_name)).'&nbsp;'.$year;  #note that some locales don't capitalize month and day names
  18.  
  19.     #Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
  20.    @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
  21.    if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span>&nbsp;';
  22.     if($n) $n = '&nbsp;<span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
  23.     $calendar = '<table class="calendar">'."\n".
  24.         '<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";
  25.  
  26.     if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
  27.        #if day_name_length is >3, the full name of the day will be printed
  28.        foreach($day_names as $d)
  29.             $calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
  30.         $calendar .= "</tr>\n<tr>";
  31.     }
  32.  
  33.     if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'">&nbsp;</td>'; #initial 'empty' days
  34.    for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
  35.         if($weekday == 7){
  36.             $weekday   = 0; #start a new week
  37.            $calendar .= "</tr>\n<tr>";
  38.         }
  39.         if(isset($days[$day]) and is_array($days[$day])){
  40.             @list($link, $classes, $content) = $days[$day];
  41.             if(is_null($content))  $content  = $day;
  42.             $calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
  43.                 ($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
  44.         }
  45.         else $calendar .= "<td>$day</td>";
  46.     }
  47.     if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">&nbsp;</td>'; #remaining "empty" days
  48.  
  49.     return $calendar."</tr>\n</table>\n";
  50. }
  51. echo generate_calendar(2010, 12, 16,3,NULL,0,15, $first_of_month, $day_names, $day_names[$n]);
  52. #echo generate_calendar($year, $month, $days,$day_name_length,$month_href,$first_day,$pn);
  53. ?>

el error que me da es que defina las variables que tengo dentro de la funcion cuando hago el echo.

alguna ayuda?
Saludos.