0

Can anyone tell here, what is the command to run html with php script. Normally in my linux terminal, if i want to run html, my command is

firefox <filename>.html

It works fine and display output in firefox browser. But some how, when I add php script, the browser doesn't show the output from php script. It show source code. I try the answer from the forum below, it doesn't work for me.

Using .htaccess to make all .html pages to run as .php files?

How to run a php script inside a html file?

So here, i want to ask 1) What is the step to run html with php script

2) what is the command to run?

3) The source code, need to save in .html or .php ?

Is there any way to run php in browser without using apache?

4
  • 2
    I don't understand the question. PHP scripts combined with HTML can be run directly in browsers Commented Jul 7, 2019 at 3:39
  • I'm not sure about PHP, but you can try an NPM package called 'live-server' it's easier to run a static html in a webserver Commented Jul 7, 2019 at 3:54
  • Well to run local Php scripts from a browser, you need a web server that processes the Php script and forwards the result to the browser. The Php script must be served by a web server. It cannot be processed directly by a browser Commented Jul 7, 2019 at 4:12
  • This works on this win10 box (which has a copy of xampp installed and has a copy of the specified script) "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" localhost/snippets/pdfInfo.php Commented Jul 7, 2019 at 4:42

2 Answers 2

2

Rename file.html to file.php and check. I think you write PHP and HTML in a single document, and you use only html extension.

Sign up to request clarification or add additional context in comments.

Comments

2

You can't run php codes without install PHP package on your OS. your browser can't understand your php code without this package, So your browser show source code. After that you can run php file as a page or put it into a html page by iframe html tag.

2 Comments

can you explain more on this?
php syntax code only can run with php module that you should install on your server or OS. for example you can install xampp software on to Windows OS, then you can run php codes on your system. PHP codes can compile on server side only, So you can't open php file as html file on browser without install php package.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.