Arduino does not receive data from PHP until I run tests with the serial monitor

Hi, how are you,
Thank you for reading my query, which I will tell you below:
I have been working on sending data through my serial port from PHP to Arduino UNO, but it happens that when testing from the php form nothing happens, then I open the serial monitor and everything works fine, I close the serial monitor and I return to the php application and it works correctly. When reloading the program in arduino the same thing happens, it does not work until you run a test on the serial monitor, otherwise the php application DOES NOT WORK. Working on Windows 8.1 platform (64 bit), Netbeans 8.2, Xampp 7.1.1 (Apache), and Arduino IDE 1.8.1

PHP/HTML source:

<?php 'mode COM4: BAUD=9600 PARITY=N data=8 stop=1 xon=off'; $fp = fopen ("COM4:", "w+"); if (!$fp) { echo "Error al abrir COM 4."; } else { $datos= escapeshellcmd($_REQUEST["numero"]); fputs ($fp, $datos ); fclose ($fp); } ?> Par o impar

enciende led

Ingresar un n° 3 para encender LED.

Escribe un número:

Arduino source:
int ledPin = 13;
int input = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
Serial.write(“conectado”);
delay(1000);
}

void loop() {
if (Serial.available() > 0) {
input = Serial.read();
}
if (input > 0) {
if (input == ‘3’){
digitalWrite(ledPin, HIGH);
delay(1000);
}
else {
digitalWrite(ledPin, LOW);
delay(1000);
}
input = 0;
}
}

thanks you…!

Your php script does not maintain the serial connection open, when the script has finished running the port is probably closed.

Also with a uno, opening the serial console to the arduino port will reset the arduino, may be would be good to wait a bit before sending something on that serial, the uno might not be ready yet

puede ser por falta de alguna librería?

todosucedeporalgo: puede ser por falta de alguna librería?

Say what?