Req #77684 [Com]: print with newline

From: Date: Sat, 02 Mar 2019 02:54:36 +0000
Subject: Req #77684 [Com]: print with newline
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219809@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77684&edit=1 ID: 77684 Comment by: svnpenn at gmail dot com Reported by: svnpenn at gmail dot com Summary: print with newline Status: Open Type: Feature/Change Request Package: *General Issues PHP Version: 7.3.2 Block user comment: N Private report: N New Comment: @spam2 under the Internals heading 11 mailing list are shown, so thats not exactly helpful further - that pages doesnt actually show what the email address is so even if i knew the correct list how would i even send a message Previous Comments: ------------------------------------------------------------------------ [2019-03-02 02:50:38] spam2 at rhsoft dot net it has not that many ctrl+f "internals" while I must say that only the idea change the default here is insane to say it polite ------------------------------------------------------------------------ [2019-03-02 02:43:48] svnpenn at gmail dot com @requinix that page has literally 20 mailing lists perhaps you could name a specific one so that your suggestion will be constructive? ------------------------------------------------------------------------ [2019-03-01 16:46:41] requinix@php.net 1 would break *lots* of backwards compatibility so it isn't even remotely an option. 2 is reasonable, though "say" doesn't really fit the PHP naming style. 3 seems to be the result of confusing this language with Perl. Adding a new function/construct like "println" or "echoln" or whatever isn't too drastic a change, but you should still hop on the internals mailing list and see what people think about this idea. http://php.net/mailing-lists.php ------------------------------------------------------------------------ [2019-03-01 02:39:46] svnpenn at gmail dot com Description: ------------ with PHP, several methods are available to produce output: echo "hello world\n"; print "hello world\n"; print_r("hello world\n"); var_export("hello world\n"); However all these methods have something in common: they do not produce their own newline. With each method, the user is required to provide a newline with "\n", PHP_EOL or similar. This is bothersome because many other programming languages offer such a method. For example Python: print('hello world') Perl: use feature say; say 'hello world'; Ruby: puts 'hello world' Lua: print 'hello world' Even C: #include <stdio.h> int main() { puts("hello world"); } Out of the above examples, I would say Perl and Ruby are most similar to PHP, in that they also have the "print" method: $ perl -e 'print 2; print 3;' 23 $ ruby -e 'print 2; print 3;' 23 However even in this case, "print" can be made to produce a newline by default: $ perl -e '$\ = "\n"; print 2; print 3;' 2 3 $ ruby -e '$\ = "\n"; print 2; print 3;' 2 3 My request would be, in order of preference: 1. the "echo" method be modified such that it produces newline by default 2. new method method be added, perhaps "say", that produces newline by default 3. a variable be introduced, "$\" or similar, that controls output record separator I understand that some of these methods are decades old and unlikely to change, but if I do nothing then I have only myself to blame. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77684&edit=1

« previous php.bugs (#219809) next »