Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jun 15, 2019

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");
}

To resolve, implement PHP println function.

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");
    }

To resolve, implement PHP "println" function.
@salarmehr
Copy link

salarmehr commented Jun 24, 2019

The idea is great in particular for CLI scripting. But it would be better to introduce a language structure similar to echo to not to have to use brackets and a shorter name as puts (same as ruby and C) otherwise adding . PHP_EOL to end of echo statement has a similar outcome.

echo 'Hi!'.PHP_EOL vs println('Hi!')

@ghost
Copy link
Author

ghost commented Jun 24, 2019

@salarmehr this has already been discussed at length on the mailing list and in
the other pull request.

The name is not changing as far as I am concerned. However having it as a
language construct would be prefered, but I do not have the time or motivation
to do that at this point. Thanks

@nikic
Copy link
Member

nikic commented Jul 15, 2020

Closing this, as the author turned into a ghost...

@nikic nikic closed this Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants