Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16830

Re: echo "<br>" wouldn't print a new line

Path csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.php
Subject Re: echo "<br>" wouldn't print a new line
Date Wed, 6 Jul 2016 13:49:53 +0200
Organization solani.org
Lines 41
Message-ID <nlir90$t8g$1@solani.org> (permalink)
References <83e11700-3227-43a8-bf36-ab77004976e6@googlegroups.com> <nldd7c$so7$1@solani.org> <11587625.uLZWGnKmhe@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1467805792 29968 eJwNzMkNADEIBMGUhnMhHIMh/xDW6m+pTZy8P3VztbW9KTFb2BhryrWaypS+AeJur2LUiaO8ihwwkaXPd6ShSjqBJytsM2HnvVmnX7hCHPwDrVweFA== (6 Jul 2016 11:49:52 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Wed, 6 Jul 2016 11:49:52 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1
X-User-ID eJwFwQEBACAIA7BM4OFYBzn9I7jFSctHZCRiY9urFwwTTkwP/JY87RZ9CRNnXrlIWR/VBxUvEOw=
In-Reply-To <11587625.uLZWGnKmhe@PointedEars.de>
Cancel-Lock sha1:Ss1l+3mxa9+fSaxspuDoFlhfxHk=
X-NNTP-Posting-Host eJwNxcEBwCAIA8CViEKAcRRk/xHa+5xtguVKo9rYZM8x3NAkarHklE5lyV1rC4AR19gitv/D12uNkzVgzFEKeu4oELHf6/JoRz/S88hlfmmXHZ0=
Xref csiph.com comp.lang.php:16830

Show key headers only | View raw


On 05.07.2016 at 21:43, Thomas 'PointedEars' Lahn wrote:

> Christoph M. Becker wrote:
> 
>> `echo` just prints the arguments it's given.  There's no magic involved.
> 
> There is, literally, a little bit of magic involved: “echo” and “print” 
> print their respective arguments as if they had been typecast to string.  
> That is, if you are “echo”ing or “print”ing an object, and that object 
> inherits a “magic” __toString() method, then the return value of that method 
> (typecast to string if necessary), is printed:

You're right, but I don't consider this to be really special behavior of
echo/print.  Actually that behavior is the same for all (built-in)
functions and operators expecting (a) string(s).

>>  `echo <br>` will never print a new line.
> 
> Well, to begin with, that is _not_ what *they* used.

Thanks for correcting the typo. :)

> Probably the OP is unaware that PHP can run in different environments, and 
> that the tutorial they are using contains exercises for the environment of a 
> HTML user agent as that is the most common way to use PHP, the PHP 
> *Hypertext* Preprocessor.  Whereas the OP has attempted to run the code 
> using the Command-Line Interface (CLI) version of PHP since they are 
> accustomed to executing programs on the command line from the (little) C 
> development experience they have.

Actually, I was aware of that, but I've chosen to ignore it, because PHP
tutorials should mention that (at least as a side note).  Unfortunately,
many don't, and in my experience a lot of PHP programmers are not aware
of the CLI SAPI, so it's probably a good idea to point that out.
<http://php.net/manual/en/features.commandline.php> appears to be a good
starting point for those not yet accustomed using the command line
interface, which can save a lot of time (for instance, wrt. to quick
experiments).

-- 
Christoph M. Becker

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

echo "<br>" wouldn't print a new line Alla <modelling.data@gmail.com> - 2016-07-04 03:06 -0700
  Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-04 12:14 +0200
  Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-04 12:19 +0200
    Re: echo "<br>" wouldn't print a new line Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-05 21:43 +0200
      Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-06 13:49 +0200
        Re: echo "<br>" wouldn't print a new line Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-06 20:57 +0200
  Re: echo "<br>" wouldn't print a new line Alla <modelling.data@gmail.com> - 2016-07-04 09:38 -0700
  Re: echo "<br>" wouldn't print a new line Tim Streater <timstreater@greenbee.net> - 2016-07-04 12:30 +0100
  Re: echo "<br>" wouldn't print a new line Arno Welzel <usenet@arnowelzel.de> - 2016-07-09 17:43 +0200
    Re: echo "<br>" wouldn't print a new line Sebastiaan Kop <sebastiaan@famkop.nl> - 2016-07-24 16:14 +0000
      Re: echo "<br>" wouldn't print a new line Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-07-30 14:03 -0400
        Re: echo "<br>" wouldn't print a new line Jivanmukta <jivanmukta@poczta.onet.pl> - 2016-07-30 20:08 +0200
          Re: echo "<br>" wouldn't print a new line Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-07-30 17:18 -0400
        Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-31 13:28 +0200
          Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-31 15:28 +0200
            Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-07-31 17:38 +0200
              Re: echo "<br>" wouldn't print a new line "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-08-01 14:57 +0200
                Re: echo "<br>" wouldn't print a new line "R.Wieser" <address@not.available> - 2016-08-01 15:18 +0200
      Re: echo "<br>" wouldn't print a new line "J.O. Aho" <user@example.net> - 2016-07-31 08:17 +0200

csiph-web