2

How do I run a PHP file in my browser? I know what the file is for and I know how it looks because I tested it online. But now I downloaded it locally to my computer and I do not know how to run it on my browser. Is there a way maybe to link it to a HTML like you do with JavaScript or CSS to make it work on a web browser also after it is online how will I manage it to work?

If I can not link then maybe I can use iframe to see it in a HTML iframe. Is that possible? Yet the question is not based about iframe, but I do not exclude the iframe possibility too. That is why I ask of it too.

Or even better, if there is a way to both link and use iframe for the PHP?

The entire PHP file I got is a email function that works and looks a loot like a HTML and JavaScript file, but it is written in PHP. If I simply change the name to the file from PHP to HTML I can open it in the browser and it looks like a HTML file with few defects since it is a PHP file after all.

The file I downloaded was from here: https://www.hscripts.com/scripts/php/registrationMailer.php

And it is this PHP file I am specifically intrested in: https://www.hscripts.com/scripts/php/HMAD/hmailer.php

NOTE: I am not asking of "PHP code is not being executed, instead code shows on the page" as the other page is asking. I am asking of "How do I show / run a PHP file in a browser? As if it was a webpage."

SeekLoad
  • 973
  • 1
  • 9
  • 33

2 Answers2

7

You do not need a web server to execute PHP script unless you need to run it using a browser. Install PHP in your operating system and include PHP path in your environment path or variable (depending on what OS) you are using. If you are just using the script for the mailing stuff from your own computer, you don't need a web server like apache, you just need PHP and its cli program installed and you be run php scripts directly. Google the web how on how run PHP command line. Or visit this official documentation link: http://php.net/manual/en/features.commandline.php

TurtleTread
  • 1,297
  • 2
  • 12
  • 23
  • 1
    As for inclusion of the PHP script in iframe, this means you will indeed need a web server to handle http requests and run your scripts. Easy solutions are web development environment packages like WAMP if are using windows. If you are using Mac or Linux system, I encourage you to install PHP, Apache and MySQL separately on your own because you will learn more if you are seriously considering doing web development. – TurtleTread Apr 15 '17 at 23:24
  • As for web servers I use to have Linux, but my new laptop is fcked up. It refuses any ddsitro what so ever. I tried everything, so do not tell me of Ubuntu, I tried that too. In my life I had dussins of Linux as I use to have a doal boot system on all my laptops. But this is the first laptop I ever had to not install Linux, because it refuses to install it. So the QUESTION is: How do I make PHP to work offline when I have naither Linux or Mac. By the way I "HATE" Macintosh systems, but love Linux. @TurtleTread – SeekLoad Apr 16 '17 at 15:28
  • Yes, like I mentioned earlier, use WAMP for the web dev environments on Windows. www.wampserver.com You will need to look up how to configure wamp to setup virtualhosts on apache and etc. But for starters, you can start programming PHP in its default document root directory. – TurtleTread Apr 16 '17 at 16:37
3

You need to download a server, and install it. If you want to go to the trouble, you can get XAMPP, and once it's installed, move the PHP file to the root of your installation (usually c:\xampp\htdocs\ on windows) and then use the url localhost/script.php in your browser.

yaakov
  • 4,568
  • 4
  • 27
  • 51