php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Omitting a parameter in printf() doesn't create Error

Open sebastienserre opened this issue 4 years ago • 1 comments

Description

The following code:

<?php
printf(
		'my test',
	);

Resulted in this output:

my test

But I expected this output instead:

Parse error: syntax error, unexpected ')' in /in/NfddB on line 4

Process exited with code 255.

In the example the second parameters has been omitted and from PHP7.3, it doesn't create any error. I think the PHP7.3 behaviour should be restored.

PHP Version

PHP 8.0

Operating System

Ubuntu 20.04

test made:

https://3v4l.org/NfddB https://3v4l.org/NfddB#v7.2.34

sebastienserre avatar Jan 19 '22 10:01 sebastienserre

PHP allows trailing commas in function calls since PHP7.3. https://wiki.php.net/rfc/trailing-comma-function-calls

Thus this actually is a feature, not a bug. :wink:

iluuu1994 avatar Jan 19 '22 10:01 iluuu1994