php-windows Digest 16 Dec 2003 21:00:03 -0000 Issue 2044

Topics (messages 22390 through 22393):

Re: Inconsistent php sematics witrh trim() ... or can't trim() handle  assignment with 
same variable?
        22390 by: Svensson, B.A.T. (HKG)
        22391 by: Sven Schnitzke

Re: Inconsistent php sematics witrh trim() ... or can't trim() handle  assignment with 
same variable? - "EXPLAINED!!"
        22392 by: Svensson, B.A.T. (HKG)

HTTP header treatment IIS6 & PHP
        22393 by: Erik Finnman

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I wish I could say the same about my code, but your
remark is still fruitfull from some points of view:

1) It does work in your special case, but not with me.
2) It does not tell anything about my case.
3) It does tell - me - something about my case!

Conclusion: I need to run some few test suits
today to find out what's really going on here.

In addition I can tell that my file consist of NL as CR+LF,
or if it was the otherway around (LF+CR) - I never seams to
be able to remember the order. ;) According to 3) your NL (\n)
might encode different: either CR or LF only(?). On the other
hand trim() does acutally remove the NL when called as in the
second code example, so it can't just be the simple fact that
it does remove one, and only one, of the NL characters from
the string.

It might be an idea to investigte the input/output relation
with trim() in order to find out weather any of CR or LF (or
both) is left in the output string after trim() been applied.

The major point is thou that I do experience that trim() have
two different kind of behaviour depending on the way I call
trim(), so the question(s) is(are): what is the scope of this
behavior, and why does it happend (to me;)?

I'll try to come up with an answer on this today.


     //Anders - who never been writing php code before. ;)


-----Original Message-----
From: Frank M. Kromann
To: Svensson, B.A.T. (HKG)
Cc: '[EMAIL PROTECTED]'
Sent: 2003-12-16 07:20
Subject: Re: [PHP-WIN] Inconsistent php sematics witrh trim() ... or can't
trim() handle  assignment with same variable?

I can't see a promlem with the trim() function.

Try this:

<?php

$a = " test\n";
echo "***$a***";
$a = trim($a);
echo "***$a***";
?>

output:

*** test
******test***

I have tested with both php4 and php5 from cvs.

- Frank

> Just ran into this annoying thing today:
> 
> 
> Why does this /NOT/ work to remove NL's:
> 
>     $AccNr = fgets($fp);
>     while ( !feof($fp) ) {
> 
>        $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE
>        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
>        print "<pre>$i: Inserting: $InsertStr </pre>";
>        ob_flush();
>        mssql_query($InsertStr);
> 
>        $AccNr = fgets($fp);
>     }
> 
> while this works just fine to remove NL's:
> 
>     $AccNR = trim( fgets($fp) );  // trim WORKS JUST FINE HERE
>     while ( !feof($fp) ) {
> 
>        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
>        print "<pre>$i: Inserting: $InsertStr </pre>";
>        ob_flush();
>        mssql_query($InsertStr);
> 
>        $AccNr = trim( fgets($fp) ); // trim WORKS JUST FINE HERE
> 
>     }
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Hello Anders,

fyi: \n is LF only (ASCII 10), \r is CR only (ASCII 13), Win newline is 
CRLF or \r\n and linux/unix newline is \n. LFCR is not a valid newline, 
so maybe this is the trouble. 
Wild guess: trim trims spaces, tabs and any kind of newline 
(so called white space) but no standalone CRs.

HTH
-- 
Sven

> -----Ursprüngliche Nachricht-----
> Von:  Svensson, B.A.T. (HKG) [SMTP:[EMAIL PROTECTED]
> Gesendet am:  Dienstag, 16. Dezember 2003 09:35
> An:   'Frank M. Kromann '
> Cc:   ''[EMAIL PROTECTED]' '
> Betreff:      RE: [PHP-WIN] Inconsistent php sematics witrh trim() ... or can't      
>  trim() handle  assignment with same variable?
> 
> I wish I could say the same about my code, but your
> remark is still fruitfull from some points of view:
> 
> 1) It does work in your special case, but not with me.
> 2) It does not tell anything about my case.
> 3) It does tell - me - something about my case!
> 
> Conclusion: I need to run some few test suits
> today to find out what's really going on here.
> 
> In addition I can tell that my file consist of NL as CR+LF,
> or if it was the otherway around (LF+CR) - I never seams to
> be able to remember the order. ;) According to 3) your NL (\n)
> might encode different: either CR or LF only(?). On the other
> hand trim() does acutally remove the NL when called as in the
> second code example, so it can't just be the simple fact that
> it does remove one, and only one, of the NL characters from
> the string.
> 
> It might be an idea to investigte the input/output relation
> with trim() in order to find out weather any of CR or LF (or
> both) is left in the output string after trim() been applied.
> 
> The major point is thou that I do experience that trim() have
> two different kind of behaviour depending on the way I call
> trim(), so the question(s) is(are): what is the scope of this
> behavior, and why does it happend (to me;)?
> 
> I'll try to come up with an answer on this today.
> 
> 
>      //Anders - who never been writing php code before. ;)
> 
> 
> -----Original Message-----
> From: Frank M. Kromann
> To: Svensson, B.A.T. (HKG)
> Cc: '[EMAIL PROTECTED]'
> Sent: 2003-12-16 07:20
> Subject: Re: [PHP-WIN] Inconsistent php sematics witrh trim() ... or can't
> trim() handle  assignment with same variable?
> 
> I can't see a promlem with the trim() function.
> 
> Try this:
> 
> <?php
> 
> $a = " test\n";
> echo "***$a***";
> $a = trim($a);
> echo "***$a***";
> ?>
> 
> output:
> 
> *** test
> ******test***
> 
> I have tested with both php4 and php5 from cvs.
> 
> - Frank
> 
> > Just ran into this annoying thing today:
> > 
> > 
> > Why does this /NOT/ work to remove NL's:
> > 
> >     $AccNr = fgets($fp);
> >     while ( !feof($fp) ) {
> > 
> >        $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE
> >        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
> >        print "<pre>$i: Inserting: $InsertStr </pre>";
> >        ob_flush();
> >        mssql_query($InsertStr);
> > 
> >        $AccNr = fgets($fp);
> >     }
> > 
> > while this works just fine to remove NL's:
> > 
> >     $AccNR = trim( fgets($fp) );  // trim WORKS JUST FINE HERE
> >     while ( !feof($fp) ) {
> > 
> >        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
> >        print "<pre>$i: Inserting: $InsertStr </pre>";
> >        ob_flush();
> >        mssql_query($InsertStr);
> > 
> >        $AccNr = trim( fgets($fp) ); // trim WORKS JUST FINE HERE
> > 
> >     }
> > 
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi all,

I actually tried to replicate my problem this morning for a coulegue
of mine, but I did not manage!! I were very  astonished by that fact.
However, the explanation is probaly something like this:


I though I did this:

     while ( !feof($fp) ) {

        $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE

        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
        [....]
 
        $AccNr = fgets($fp);
     }


while I (hypothetical) in fact did (must have done) this:


     while ( !feof($fp) ) {

        $AccNr = fgets($fp);

        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
        [....]
 
        $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE
     }

That's the only way I can explain why I was not able to
replicate it this morning. 

Sorry for wasting your time - but I was probably tired yesterday evening.


-----Original Message-----
From: [EMAIL PROTECTED]
To: '[PHP-WIN]'
Sent: 2003-12-16 11:16
Subject: AW: [PHP-WIN] Inconsistent php sematics witrh trim() ... or can't
trim() handle  assignment with same variable?

Hello Anders,

fyi: \n is LF only (ASCII 10), \r is CR only (ASCII 13), Win newline is 
CRLF or \r\n and linux/unix newline is \n. LFCR is not a valid newline, 
so maybe this is the trouble. 
Wild guess: trim trims spaces, tabs and any kind of newline 
(so called white space) but no standalone CRs.

HTH
-- 
Sven

> -----Ursprüngliche Nachricht-----
> Von:  Svensson, B.A.T. (HKG) [SMTP:[EMAIL PROTECTED]
> Gesendet am:  Dienstag, 16. Dezember 2003 09:35
> An:   'Frank M. Kromann '
> Cc:   ''[EMAIL PROTECTED]' '
> Betreff:      RE: [PHP-WIN] Inconsistent php sematics witrh trim() ...
or can't        trim() handle  assignment with same variable?
> 
> I wish I could say the same about my code, but your
> remark is still fruitfull from some points of view:
> 
> 1) It does work in your special case, but not with me.
> 2) It does not tell anything about my case.
> 3) It does tell - me - something about my case!
> 
> Conclusion: I need to run some few test suits
> today to find out what's really going on here.
> 
> In addition I can tell that my file consist of NL as CR+LF,
> or if it was the otherway around (LF+CR) - I never seams to
> be able to remember the order. ;) According to 3) your NL (\n)
> might encode different: either CR or LF only(?). On the other
> hand trim() does acutally remove the NL when called as in the
> second code example, so it can't just be the simple fact that
> it does remove one, and only one, of the NL characters from
> the string.
> 
> It might be an idea to investigte the input/output relation
> with trim() in order to find out weather any of CR or LF (or
> both) is left in the output string after trim() been applied.
> 
> The major point is thou that I do experience that trim() have
> two different kind of behaviour depending on the way I call
> trim(), so the question(s) is(are): what is the scope of this
> behavior, and why does it happend (to me;)?
> 
> I'll try to come up with an answer on this today.
> 
> 
>      //Anders - who never been writing php code before. ;)
> 
> 
> -----Original Message-----
> From: Frank M. Kromann
> To: Svensson, B.A.T. (HKG)
> Cc: '[EMAIL PROTECTED]'
> Sent: 2003-12-16 07:20
> Subject: Re: [PHP-WIN] Inconsistent php sematics witrh trim() ... or
can't
> trim() handle  assignment with same variable?
> 
> I can't see a promlem with the trim() function.
> 
> Try this:
> 
> <?php
> 
> $a = " test\n";
> echo "***$a***";
> $a = trim($a);
> echo "***$a***";
> ?>
> 
> output:
> 
> *** test
> ******test***
> 
> I have tested with both php4 and php5 from cvs.
> 
> - Frank
> 
> > Just ran into this annoying thing today:
> > 
> > 
> > Why does this /NOT/ work to remove NL's:
> > 
> >     $AccNr = fgets($fp);
> >     while ( !feof($fp) ) {
> > 
> >        $AccNr = trim($AccNr);  /// trim() DOES NOT WORK HERE
> >        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
> >        print "<pre>$i: Inserting: $InsertStr </pre>";
> >        ob_flush();
> >        mssql_query($InsertStr);
> > 
> >        $AccNr = fgets($fp);
> >     }
> > 
> > while this works just fine to remove NL's:
> > 
> >     $AccNR = trim( fgets($fp) );  // trim WORKS JUST FINE HERE
> >     while ( !feof($fp) ) {
> > 
> >        $InsertStr = "insert into $UpLoadTable values ('$AccNr')";
> >        print "<pre>$i: Inserting: $InsertStr </pre>";
> >        ob_flush();
> >        mssql_query($InsertStr);
> > 
> >        $AccNr = trim( fgets($fp) ); // trim WORKS JUST FINE HERE
> > 
> >     }
> > 
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi all,
When using a PHP script to pass headers to the webserver, there seems to be
someting strange happening when using IIS6. On my development machine (IIS5,
Win2000 Professional, PHP 4.3.4), the following PHP script produces the
expected
result:

<?php
    header("HTTP/1.1: 204 No Response");
?>

i.e. the current web page is _not_ reloaded when the script is called. But
on a IIS6 machine (PHP version 4.3.3, running on Win 2003 Server), a blank
page is returned. Using telnet, the following result was send from the
webserver:

HTTP/1.1 200 OK
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: PHP/4.3.3
X-Powered-By: ASP.NET
MicrosoftOfficeWebServer: 5.0_Pub
Date: Mon, 15 Dec 2003 14:31:38 GMT
Connection: close

As you can see, the server returns HTTP header 200 instead of 202. The same
happens when using e.g. HTTP 404, om my machine the correct error is sent,
but on the IIS6, still the same HTTP 200 is sent.

Are the headers treated differently in IIS6? Does the script need some
additional text for this to work?

Looking forward to your replies,
Erik Finnman

--- End Message ---

Reply via email to