ID:               22407
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dci at webquill dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: FBSD 4.6-RELEASE
 PHP Version:      4.2.3
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2003-02-24 17:29:52] dci at webquill dot com

I did note something similar in bug #10858, but that was in regards to
an older version of PHP and it seemed like the feedback was never
provided to solve the issue.

We've got code that is in a Unix formatted text file, and on one of the
lines, we somehow ended up with a literal ^M character (a DOS newline
feed).  Although this had nothing to do with PHP, it produced very
strange results -- the line in question began with a single line
comment ( // ), and the ^M was in the middle followed by an old if
statement.  I suspect this came about because our code was originally a
quick conversion from an ASP site utilizing asp2php.  The odd part,
however, is that even tho editors (vim, emacs) would show the line as
being a comment, and on one line, PHP would interpret the ^M as a
newline, and then parsed the code after it.  Because this was a
comparison between 0 and a variable that did not exist (thus returning
0), the new comparison for the if, which was on the next line, was
never processed.  Here is some example code (I am afraid I cannot
provide full-code due to restrictions placed on me by my employer):

  error_log( "SQL: $ssql" );
  $res = pg_query( $dbconn, $ssql );
  error_log( "pg_last_error: " . pg_last_error($dbconn) );
  error_log( "Number of results: " . pg_num_rows($res) );

  //only send if there's an Email to send to^M  if (!($get_email==0))
  if( pg_num_rows($res) > 0 ){
    error_log( "here" );

The line beginning with // and ending with ($get_email==0)) is all one
line.  The first error_log showed the correct SQL, pg_last_error
reported to errors, and pg_num_rows correctly logged 1 result row.  We
discovered the problem when the error_log("here") statement was never
being executed.  Upon removing the ^M character, everything performed
as expected, and the "here" statement was logged in the error_log.  The
following code was then executed.

Now I realize that this could potentially be by design, because of the
cross-platform nature of web development (due to all those silly
Windows users out there and their bad character set ;), but I would
suspect that if the entire file is being parsed as a particular format
text file that characters not indicating a linefeed in that format
should not be interpreted as such.  It is my guess (without taking time
to examine the PHP source code) that PHP is not examining the file type
and is merely interpreting all linefeed characters as new lines and not
determining file format.

A thought after finally tracking down a very odd problem..  Other than
that, thank you for a wonderful product!

-chris

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22407&edit=1

Reply via email to