Skip to content

getopt with required value should not assign the next --opt as value, if no value provided #19555

@kkmuffme

Description

@kkmuffme

Description

The following code:
php opts.php --foo --bar="hello"

<?php

$longopts = array( 'foo:' );
$options = getopt('', $longopts);
var_dump($options);

Resulted in this output:

array(1) {
  ["foo"]=>
  string(11) "--bar=hello"
}

But I expected this output instead:

array(1) {
  ["foo"]=>
  string(0) ""
}

PHP Version

PHP 8.3.24

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions