Well, I already replied about this problem earlier, and today, I was doing the same thing, and I faced a different error while running the PHP script in Xampp. Later, I searched for it on the internet, and I found that there was some setup issue with it. I have seen
https://www.techgeekbuzz.com/blog/how-to-run-php-program-in-xampp/ on the internet and followed all the steps from scratch, and it helped me to fix the issues. If you are also facing the same issue, then you can also follow.
Thanks