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 one of the following:
-
Modify one or more of "print", "print_r", "var_export" such that they produce
a newline by default -
Modify one or more of "print", "print_r", "var_export" such that they have an
argument similar to Python "end" that controls what follows the input, if
anything: -
Add a new method, perhaps "echoln", "println", "say" or similar, that outputs
a newline by default -
introduce a new variable, perhaps "$OUTPUT_RECORD_SEPARATOR", "$ORS", "$" or
similar, that controls output record separator
I understand that some of these methods are old and unlikely to change, but if I
do nothing then I have only myself to blame.