[bug] PHP error_log() not properly working

Scenario:

  • go to Coders Strike Back
  • select PHP as language
  • add error_log(var_export("test", true)); just before the echo() instruction
  • run the code

Expected behaviour:

  • the console displays in error output one test per turn

Current behaviour:

  • the console displays in error output two test per turn

Additional information:

  • this error leads to a widening gap between the turn of the debug display and the turn of the echo, you can test it by using an incremented value in the error_log() and in the echo() to see the difference

I can’t reproduce the issue you’re describing in my IDE or using your code. Could you please PM the code with which you have this problem?

<?php
while (TRUE)
{
    // $x: x position of your pod
    // $y: y position of your pod
    // $nextCheckpointX: x position of the next check point
    // $nextCheckpointY: y position of the next check point
    // $nextCheckpointDist: donne la distance entre votre pod et le prochain checkpoint
    // $nextCheckpointAngle: donne la diff d'angle entre votre pod et le prochain checkpoint
    fscanf(STDIN, 
            "%d %d %d %d %d %d", 
            $x,
            $y,
            $nextCheckpointX,
            $nextCheckpointY,
            $nextCheckpointDist,
            $nextCheckpointAngle
    );

    // To debug: error_log(var_export($var, true)); (equivalent to var_dump)

    error_log(var_export("test", true));
    echo ($nextCheckpointX . " " . $nextCheckpointY . " 100\n");
}
?>

Here have a screenshot of my debug console: https://i.ibb.co/jRMTzBC/image.png

I’m using Firefox 76.0.1 (64 bits) on Windows 10 Pro N version 1809 - 17763.1158

you forgot to read one line of input (the opponent position). So you output one line every time you read one line. But a turn is two lines of input so every turn, you send 2 commands. So you’re desynchronizing the input from the output

1 Like

Oh yes my bad :no_mouth: Thanks a lot!

1 Like