This is a discussion on New line characters and carriage returns within the PHP General forums, part of the PHP Programming Forums category; Ok, don't know what I am doing wrong here...but for some reason I cannot get new line or ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Ok, don't know what I am doing wrong here...but for some reason I cannot
get new line or carriage return characters to work correctly... For example, When I send some emails, I try $msg .= "From: me@mydomain.com\r\n Content-Type: text/plain\r\n" And it doesn't work correctly... the Content Type shows in my mail body.... More importantly, I'm trying to write a system logger $fileName = 'errors.'.date('dmY').'.log'; $error = date('h:i:s').' '.$script.' '.$error.'\n'; error_log ($error, 3, '/var/www/killerspin/logs/'.$fileName); but the output into my log file shows the \n but does not use it. |
|
|||
|
ok, I see, I have to use double quotes around it...
why is that? On Fri, 2003-10-24 at 11:57, Jonathan Villa wrote: > Ok, don't know what I am doing wrong here...but for some reason I cannot > get new line or carriage return characters to work correctly... > > For example, > > When I send some emails, I try > > $msg .= "From: me@mydomain.com\r\n > Content-Type: text/plain\r\n" > > And it doesn't work correctly... the Content Type shows in my mail > body.... > > > More importantly, I'm trying to write a system logger > > $fileName = 'errors.'.date('dmY').'.log'; > $error = date('h:i:s').' '.$script.' '.$error.'\n'; > error_log ($error, 3, '/var/www/killerspin/logs/'.$fileName); > > but the output into my log file shows the \n but does not use it. |
|
|||
|
on 10/24/03 10:00, Jonathan Villa at jvilla@isdesigndev.com wrote:
> ok, I see, I have to use double quotes around it... > > why is that? Because they actually have to be evaluated.. when they are in single quotes php thinks they are the string \r\n and not newline or carriage returns that they are when you use double quotes.. otherwise there would be no way of echoing '\r\n' if php always thought they were newlines or carriage returns. Cheers! Rick > On Fri, 2003-10-24 at 11:57, Jonathan Villa wrote: >> Ok, don't know what I am doing wrong here...but for some reason I cannot >> get new line or carriage return characters to work correctly... >> >> For example, >> >> When I send some emails, I try >> >> $msg .= "From: me@mydomain.com\r\n >> Content-Type: text/plain\r\n" >> >> And it doesn't work correctly... the Content Type shows in my mail >> body.... >> >> >> More importantly, I'm trying to write a system logger >> >> $fileName = 'errors.'.date('dmY').'.log'; >> $error = date('h:i:s').' '.$script.' '.$error.'\n'; >> error_log ($error, 3, '/var/www/killerspin/logs/'.$fileName); >> >> but the output into my log file shows the \n but does not use it. |
|
|||
|
* Thus wrote Jonathan Villa (jvilla@isdesigndev.com):
> Ok, don't know what I am doing wrong here...but for some reason I cannot > get new line or carriage return characters to work correctly... > > For example, > > When I send some emails, I try > > $msg .= "From: me@mydomain.com\r\n > Content-Type: text/plain\r\n" > $msg .= "From: me@mydomain.com\r\nContent-Type: text/plain\r\n"; Your mail Program is seeing: From: me@mydomain.com Content-Type: text/plain The empty line tells the program that it has reached the end of headers. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ |
|
|||
|
Jonathan Villa wrote:
> > $msg .= "From: me@mydomain.com\r\n > Content-Type: text/plain\r\n" > PHP is retaining the implicit linefeed in the text so there is a blank line between From and Content-Type, the end-of-header indicator. (You must have a dos-ish system.) Change it to: $msg .= "From: me@mydomain.com\r\n" . "Content-Type: text/plain\r\n"; > > $fileName = 'errors.'.date('dmY').'.log'; > The log files will sort a lot more sensibly if you use 'Ymd'. -- jimoe at sohnen-moe dot com |