I spent the last few hours stretching my hair, trying to figure out a solution to this problem. I am sending an AJAX request that, up to some minor changes, worked just fine, returning a beautiful character Javascript. Now, however, \ r \ n is returning, and I have been tracking it for too long. My last way to find where it was turned on was to literally echo "OMG" in different places around my scripts until it appeared on line 2 of HTML instead of line 1. Here is an insulting script:
// Import Global Game Variables include('../engine/engine_core_functions.php'); // Convert our gamestate(gameID) //$curGamestate = getCurrentGamestate($gameID); // Make sure it a valid turn if(isMyTurn()) { // Draw a card from the card drawing mechanism $cardValue = drawCard(); $cardValue = str_replace("\r", 'R', $cardValue); echo $cardValue; } else echo 'Error 3';
A line is skipped immediately after including a file at the top. Before turning on, there is no line break after turning on the line. So I go to the included file. Posting my
echo 'OMG!';
VERY END of the included file DOES NOT break the line. This led me to believe that even a file can (why !?) generate a line break (it's 5 AM ...). However, there are several included files at the top of the file associated with the violation. None of them create breaks. The whole "engine_core_functions.php" does not create line breaks at all.
However, the gap is displayed when it is included in the script shown above. Needless to say, I am puzzled and extremely annoyed. I could just remove the offensive characters (via PHP or Javascript), but it annoys me, I cannot fix the root of the problem. Please help, thanks.
source share