php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27097 checkdate asks for long doc says int
Submitted: 2004-01-30 08:00 UTC Modified: 2004-04-15 12:48 UTC
Votes:53
Avg. Score:1.3 ± 0.9
Reproduced:5 of 9 (55.6%)
Same Version:-1 (-20.0%)
Same OS:-2 (-40.0%)
From: trancer at trancer dot nl Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: 4.3.4 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: trancer at trancer dot nl
New email:
PHP Version: OS:

 

 [2004-01-30 08:00 UTC] trancer at trancer dot nl
Description:
------------
Had the following warning:

Warning: checkdate() expects parameter 1 to be long, string given in

Documentation says:

Description
bool checkdate ( int month, int day, int year)

int should be long here or long should be int, either of them.

Might have to do with bug #25530, but still, the error issues a long while the demanded type is int. 



Reproduce code:
---------------
<?php checkdate("", "", ""); ?>

Expected result:
----------------
Warning: checkdate() expects parameter 1 to be int, string given in

Actual result:
--------------
Warning: checkdate() expects parameter 1 to be long, string given in

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-30 10:15 UTC] nlopess@php.net
The documentation is right.
You are giving a string, while it expects an integer.

You should learn more about variable types in PHP.
 [2004-01-30 10:47 UTC] derick@php.net
Nuno: And you need to learn to read ;-) He mentions that INT (from the manual) is not the same as the LONG (from the error message).
 [2004-01-30 10:48 UTC] didou@php.net
should the proto be number ?
 [2004-01-30 11:03 UTC] et@php.net
Note that "int" in php is a "signed long int"(32 bit), so int and long are equivalent. But i think you shouldn't have to know C to read error messages, so IMO the error message should change. I'll send a patch for that to the list.

Additionally, checkdate() doesn't convert to int like other php functions do, but since it's a validating function, that strictness is desirable behaviour imo, but should be documented. I'll add a note to the manual.
 [2004-01-30 11:13 UTC] derick@php.net
No, the error message is correct. We use a long, internal type is long, parse_parameters uses the "l" as type specifier... the docs needs fixing.
 [2004-01-30 11:13 UTC] et@php.net
When i think more about it, it doesn't really make sense for checkdate to accept "1e1" (which is "numeric" but not an integer) but not "1d1", so it is either too strict or not strict enough. Any thoughts?
 [2004-01-30 11:14 UTC] et@php.net
Derick: Then why does zend_zval_type_name return "integer"?
 [2004-02-02 11:04 UTC] nlopess@php.net
What should we do then?

Maybe its better to add a note to http://php.net/manual/en/language.types.php explaining that long is similar to an integer.

Ideas?
 [2004-04-15 12:48 UTC] nlopess@php.net
Since we didn't arrive to any conclusion, I'm closing this bug.
 [2012-12-07 16:22 UTC] chrisdavies at hotmail dot com
I'm checking for the format of a date using :
if  (checkdate ($month,$year,$day))   


 if the format is ok, then it's fine, if the format is wrong, checkdate dies with nasty errors, anyway around this please?

Warning: checkdate() expects parameter 3 to be long, string given in C:\Inetpub\wwwroot\dateSearch.php on line 40

should I not be using checkdate() for validation purposes?  if not, wtf is the point of checkdate()?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC