|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #31424 Make mode optional on mkdir
Submitted: 2005-01-06 03:07 UTC Modified: 2020-10-27 10:23 UTC
From: Assigned: cmb (profile)
Status: Closed Package: Directory function related
PHP Version: 5CVS-2005-01-06 (dev) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2005-01-06 03:07 UTC]
As all but the first parameter of mkdir are optional and non sequential, it makes sense to be able to pass NULL to each if a later param is required.

E.g. mkdir('some/path/foobar', null, true);

Reproduce code:
This patch adds this functionality:

Included in the report:

--- \repository\php-src\ext\standard\file.1.395.c	Mon Dec 13 10:21:53 2004
+++ \repository\php-src\ext\standard\file.c	Thu Jan 06 12:29:41 2005
@@ -1372,7 +1372,7 @@
 	char *dir;
 	php_stream_context *context;
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbr", &dir, &dir_len, &mode, &recursive, &zcontext) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|!lbr", &dir, &dir_len, &mode, &recursive, &zcontext) == FAILURE) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-10 13:55 UTC]
-Package: Feature/Change Request +Package: Directory function related
 [2018-03-10 13:55 UTC]
I fail to see why `NULL` would be preferable to the more explicit
`0777` here.  IMHO: won't fix.
 [2020-10-27 10:23 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-10-27 10:23 UTC]
As of PHP 8.0.0 you can use named arguments[1], what seems to be a
good alternative to your suggestion.  If you still feel that there
should be a way to skip default parameters without using named
arguments, please raise that on the internals mailing list[2],
since this would need discussion and an RFC[3].

[1] <>
[2] <>
[3] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jul 23 20:01:23 2021 UTC