Warning: Unable to open the device in C:\xampp\htdocs\arduino\lamp\php_serial.cl

int redPin = 7;   // pushbutton connected to digital pin 7s
int incomingbyte;     // variable to store the read value

void setup()
{
  Serial.begin(9600);
  pinMode(redPin,OUTPUT);     

void loop()
{
if (Serial.available() > 0)
{
  incomingbyte = Serial.read();
}
if(incomingbyte == '0');
{
  digitalWrite(redPin,HIGH);
  
}
  if (incomingbyte == '1');
  {
    digitalWrite(redPin, LOW);
    
  }
}

Check your 2nd and 3rd 'if' statements' format against the first 'if' statement and definition in Reference.

int redPin = 7;   // pushbutton connected to digital pin 7s
int incomingbyte;     // variable to store the read value

void setup()
{
  Serial.begin(9600);
  pinMode(redPin,OUTPUT);      // sets the digital pin 13 as output
  }

void loop()
{
if (Serial.available() > 0)
{
  incomingbyte = Serial.read();
}
if(incomingbyte == '0');
{
  digitalWrite(redPin,HIGH);
  
}
  if (incomingbyte == '1');
  {
    digitalWrite(redPin, LOW);
    
  }
}
<?php

if (isset($_GET['action'])) { 

  require('php_serial.class.php');
  $serial = new phpSerial(); 
  $serial->deviceSet("COM47");
  $serial->confBaudRate(9600);
  $serial->deviceOpen();
	
	if ($_GET['action'] == "redPin0") {
		$serial -> sendMessage("0");
	} else if ($_GET['action'] == "redPin1") {
		$serial ->sendMessage("1");
	}
	$serial ->deviceClose ();
}
?>

I am sorry if there is any beginner
I first learned arduino … what is wrong in the code so that the program can not connect Warning: Unable to open the device in

Your PHP script will open the serial port, resetting the Arduino. Without waiting for it to be ready, it will send it some data, and then close the serial port.

You might as well not bother sending any data to the Arduino.

I find it extremely difficult to believe that the Arduino is connected to COM47. If it REALLY is, there is a different naming format that you might need to use, for port numbers greater than 9.

This is the case that the arduino is on com port 47 .. what it is out of reach when it was ported com47