PHP serial output problem

    $i = (4);

Why are there () around the 4?

while (true){
    $i = (4);
    fwrite($fp, chr($i));
    sleep(3);
}

How do you expect this loop to end?

   $i = $i;

Why?

        Serial.println(usbnumber);

Why? There is nothing reading data written to the serial port?

            delay(300);
            delay(1000);

Why? You are sending serial data every 3 seconds? Why wait before checking for more?

In general, why are you changing the pin state if no new serial data has arrived?