I hope you are doing well. I have recently started learning PHP and I have a question regarding its working environment. I currently have a setup of XAMPP on my local machine, which includes Apache as the web server and MySQL as the database server. I have noticed that whenever I write PHP code, I need to save the file inside the C:\xampp\htdocs directory in order for it to work.
My question is, does PHP only work when the files are saved inside the C:\xampp\htdocs directory? Is it necessary to have a localhost setup in order to run PHP code?
I am a bit confused because I have read some tutorials where they mention that PHP files should be saved inside the htdocs directory for them to be accessible. However, I have also come across some online platforms where they allow running PHP code without setting up a local server.
Can someone please clarify this for me? I would really appreciate any insights or explanations regarding the working environment of PHP and if it is necessary to save PHP files inside the htdocs directory of XAMPP in order for them to work.
Thank you in advance for your help!