Re: RFC: Add `println(string $data = ''): int`

From: Date: Sat, 13 Mar 2021 20:16:07 +0000
Subject: Re: RFC: Add `println(string $data = ''): int`
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-113506@lists.php.net to get a copy of this message
> Hi Tyson,
> 
> I like this proposal, but why is the main argument optional? Wouldn't it
> make sense to always require a string as an argument?
> 
> Regards,
> Kamil

I initially considered making it required, but then I felt like there wasn't a compelling
reason to force end users
to write println('') instead of println() to print a single
newline in code surrounded by other println statements.
Printing an empty blank line would be common enough in CLI output or plaintext HTTP responses for
this proposal to make it easier to do.

- This differs from echo/print/printf statements, where not including an argument wouldn't make
sense to support, because it would not output anything
- This proposed println behavior is similar to python, where print() with no arguments
would print a single newline

https://wiki.php.net/rfc/println#proposal

```
println("test");
println();  // moderately useful to not switch to echo or pass the empty string to print a blank
line
println("third line");
/*
Output:
test
 
third line
*/
```

Thanks,
- Tyson


Thread (10 messages)

« previous php.internals (#113506) next »