php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #77684 print with newline
Submitted: 2019-03-01 02:39 UTC Modified: 2019-03-03 01:00 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: svnpenn at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 7.3.2 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: svnpenn at gmail dot com
New email:
PHP Version: OS:

Further comment on this bug is unnecessary.

 

 [2019-03-01 02:39 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-01 16:46 UTC] requinix@php.net
-Type: Bug +Type: Feature/Change Request
 [2019-03-01 16:46 UTC] 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-02 02:43 UTC] 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-02 02:50 UTC] 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:54 UTC] svnpenn at gmail dot com
@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
 [2019-03-02 03:55 UTC] spam2 at rhsoft dot net
WTF - http://php.net/mailing-lists.php

* there is a form
* there is "Internals list"
* there you can select which lists you want to subscribe
* below you enter your e-mail
* then you click "subscribe"
* below you see " You will be sent a confirmation mail at the address you wish to be subscribed or unsubscribed"
* as for any other mailing list you get a message
* that message explains how to post and unsubscribe

guess what: internals@lists.php.net

if that barrier is too high than for good reasons
 [2019-03-02 04:02 UTC] svnpenn at gmail dot com
@spam2 i think the "barrier" is too high for you

else you would realize that people can post to a mailing list without subscribing

however to do that, one would need to know what the email is

which is my point, that page in question *does not* list the email address

so by simple reading of the page and by your statement it is not readily possible to post without subscribing, as it should be.
 [2019-03-02 04:06 UTC] spam2 at rhsoft dot net
> people can post to a mailing list without subscribing

and you think you gain what with that when you not receive answers expect from idiots with borken mail coiuents not knowing "reply to list button" and press "reply all" to flood people with duplicate swhile you not see ny response from people knowing how to use a mailing list?

and NO post from a rndom unsibsucribed email to a list is not how it works typically because very random spambot would spread it#s shit to hundrets our thounds of subscribers unfiltered
 [2019-03-02 04:17 UTC] requinix@php.net
Feel free to ignore spam2.

The list email is internals@lists.php.net.
 [2019-03-02 15:08 UTC] svnpenn at gmail dot com
@requinix thank you

the emails have now been added:

https://reddit.com/r/PHP/comments/awd2e4/-/ehmcbig

finally is it possible to ban spam2? at best he has a tenuous grasp on english, and at worst he is actively and purposefully harming the PHP community
 [2019-03-02 15:13 UTC] spam2 at rhsoft dot net
> actively and purposefully harming the PHP community

by expect common sense while finding out the address of internals takes 10 seconds? while ideas like "1. the echo method be modified such that it produces newline by default", even the thinking about it proves lack of common sense?
 [2019-03-02 15:15 UTC] spam2 at rhsoft dot net
what would you do with "echo $a, $b, $c"?
echo is *not* a method at all to begin with
http://www.phpknowhow.com/basics/language-constructs-vs-built-in-functions/
 [2019-03-02 18:37 UTC] svnpenn at gmail dot com
@spam2 you are a professional idiot.

but as the page this bug is hosted on might exist for many years into future, i feel it my duty to give a proper refutation. results of the example you gave:

    echo $a, $b, $c;

are well defined in other programming languages. Python will print the objects separated by "sep" (default empty) and finally by "end" (default newline):

https://docs.python.org/library/functions#print

Perl will print the objects separated by "$," (default empty) and finally by "$\" (default empty):

https://perldoc.perl.org/functions/print.html

Ruby will print the objects separated by "$," (default empty) and finally by "$\" (default empty):

http://ruby-doc.org/core/Kernel.html#method-i-print

And even Awk will print the objects separated by "OFS" (default space) and finally by "ORS" (default newline):

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_10

As you have proven your poor understanding of programming languages (and the english language), i would strongly suggest that you simply stop posting. However i know this warning will fall on deaf ears. dumb has no off button.
 [2019-03-03 00:59 UTC] spam2 at rhsoft dot net
when I want the behavior of other programming languages I use them, that's why there are so many
 [2019-03-03 01:00 UTC] requinix@php.net
-Block user comment: No +Block user comment: Yes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 10:01:29 2024 UTC