Doc #53674 [ReO->Csd]: Example 1 does not work, contradicts Description

From: Date: Wed, 12 Jan 2011 13:56:29 +0000
Subject: Doc #53674 [ReO->Csd]: Example 1 does not work, contradicts Description
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5789@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53674&edit=1 ID: 53674 Updated by: danbrown@php.net Reported by: thomas dot edwards at gmail dot com Summary: Example 1 does not work, contradicts Description -Status: Re-Opened +Status: Closed Type: Documentation Problem Package: Calendar related Operating System: Mac OS X PHP Version: 5.3.5 Assigned To: danbrown Block user comment: N Private report: N New Comment: No response. Previous Comments: ------------------------------------------------------------------------ [2011-01-06 18:21:03] danbrown@php.net Ah, for the first parameter, not the return value. Gotcha'. The code worked perfectly fine for me on 5.3.4. Note that the first parameter is not encapsulated in quotes --- it's because it's an internal persistent constant which evaluates to 0 (zero). In fact, the code driving that function actually requires that each of the values be long, which is, of course, an integer variable. You mentioned in the initial report that you're using 5.3.5 on Mac. Are you using a snap or SVN checkout, or did you download the final release? Either way, if it's not working on your 5.3.5, that may indicate that it's a bug in PHP itself. What is the output of the following code? <?php $num = cal_days_in_month(CAL_GREGORIAN,1,2011); echo 'CAL_GREGORIAN shows '.$num.' days this month.'.PHP_EOL; $num = cal_days_in_month(0,2,2011); echo 'Using zero, there are '.$num.' days next month.'.PHP_EOL; ?> ------------------------------------------------------------------------ [2011-01-06 18:02:45] thomas dot edwards at gmail dot com Just tested on a different server running 5.2.8, it accepts a string or an integer! So the code does work, although can’t seem to get it to work on my 5.3.5 server, but the Example does not follow the Description. ------------------------------------------------------------------------ [2011-01-06 17:58:08] thomas dot edwards at gmail dot com In the description it says that the first variable ($calendar) is an integer, but in Example 1 it’s clearly a string. And when you run the code, neither a string or integer seems to work. ------------------------------------------------------------------------ [2011-01-06 17:32:10] danbrown@php.net Since when is 31 not an integer? ------------------------------------------------------------------------ [2011-01-06 17:27:22] thomas dot edwards at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.cal-days-in-month#Examples --- Description: int cal_days_in_month ( int $calendar , int $month , int $year ) Example 1: <?php $num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31 echo "There was $num days in August 2003"; ?> Clearly not a integer! Does not work! Test script: --------------- $num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31 echo "There was $num days in August 2003"; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53674&edit=1

« previous php.doc.bugs (#5789) next »