| 
	
 | 
 Posted by Michael on 05/28/07 05:17 
On May 27, 8:20 pm, Chris Hope <blackh...@electrictoolbox.com> wrote: 
> Michael wrote: 
> > On May 27, 8:05 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: 
> >> Michael wrote: 
> >> > I'm new to PHP. 
> 
> >> > I see that PHP supports the C printf function, and I've seen 
> >> > examples like printf("Hello world!\n"); however the newline 
> >> > character \n doesn't work - i.e., it does not generate an HTML 
> >> > <br>, which I would have expected - what it does is generate a 
> >> > newline in the html generated text, but since the browser ignores 
> >> > blank lines, this feature appears useless for most applications. 
> 
> >> >>From this arises two questions: 
> 
> >> > 1. I am misunderstanding something? 
> 
> >> > 2. What is the prescribed way of inserting a newline into a PHP 
> >> > string? (Could it be printf("Hello world! <br>") ? 
> 
> >> It works fine.  It generates a nl character, just as you asked it to. 
> >> Look at your source code - you'll see the  butline break. 
> 
> >> If you want an HTML <br> or xthtml <br />, you need to code them 
> >> yourself.  PHP does not convert for you. 
> 
> > Thanks for your reply. Yes, I looked at the source code, but no <br>, 
> > all I get is a new line of white space, which as we know is ignored by 
> > the browser. 
> 
> That's correct. You didn't ask PHP to write a <br> tag. You asked PHP to 
> write a newline break, which is exactly what it did. 
> 
> So yes, your question 2) is what you would need to do, although your 
> question should read like this: 
> 
> 2. What is the prescribed way of inserting an *html* *newline* break* 
> *tag* into a PHP string? (Could it be printf("Hello world! <br>") ? 
> 
> There is also the nl2br() function which converts "\n" to "<br />\n" 
> should you need to automatically need to do this with a string. 
> 
> -- 
> Chris Hope |www.electrictoolbox.com|www.linuxcdmall.com- Hide quoted text - 
> 
> - Show quoted text - 
 
Thank you all for your help. I now understand all of this a bit 
better.
 
  
Navigation:
[Reply to this message] 
 |