On Wed, Jan 28, 2009 at 03:06:36PM -0500, Bastien Koert wrote: > On Wed, Jan 28, 2009 at 2:58 PM, Don Collier <dcollier@xxxxxxxxxxxxxxx>wrote: > > > > >> On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote: > >> > >> > >> > >>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I > >>> have a question regarding the formatting of text. Actually it is a > >>> couple of questions. > >>> > >>> First, when I use the \n and run the script from the command line it > >>> works great. When I run the same code in a browser it does not put the > >>> newline in and the text runs together. I know that I can use <br/> to > >>> do the same thing, but why is it this way? > >>> <snip> > >> > >> > > Thanks to everyone that responded. > > From what I am seeing in the responses if I plan on using php for command > > line scripts things get written one way. If, on the other hand, the php is > > written for a web page it gets written a slightly different way inserting > > html where necessary for formatting. > > <snip> > > > Not quite true in a properly layered application. Separating the data from > the display (whatever that is) is prime idea behind the MVC (Model View > Controller) design pattern. This way your code that runs via the CLI > (command line) can produce the same data as the code that gets the data for > the HTML. The only difference is what you plan to do with that data. You > could feed it to a controller and let the controller feed it to a View to > render in a browser, or send it to a FileOutput class to create a file of > the data for comsumption by another resource. See? This is what I'm talking about. *I* understand what you're saying, Don, and I agree. But this guy is just learning PHP from what is arguably not one of the best books on PHP (IMO). And you're throwing MVC at him. Let him master the subtleties of the language first, then we'll give him the MVC speech. Yes, I know, they should learn proper programming practices from the beginning, blah blah blah. But think back to the first programming language you ever learned, when you were first learning it. If someone had thrown stuff like this at you, would you have had a clue? I had enough trouble just learning the proper syntax and library routines for Dartmouth BASIC and Pascal, without having to deal with a lot of "metaprogramming" stuff. This is the problem when you get newbies asking questions on a list whose membership includes hardcore gurus. The gurus look at things in such a lofty way that answering simple questions at the level of a beginner sounds like a dissertation on the subtleties of Spanish art in the 1500s. Just my opinion. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php