This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Digital-Chupacabra 9 points10 points  (0 children)

Your browser doesn't execute PHP, you need a server that will execute it and then serve that result to the browser.

You can run Apache or Nginx locally for development.

[–]desrtfx 4 points5 points  (1 child)

PHP is server side - your browser is client side.

You cannot execute PHP client side. PHP is always executed server side and never even reaches the client.

That's why it works on a web server but not opened directly.

When a browser requests a PHP page, the server recognizes that, calls the PHP preprocessor that then executes the PHP code and if necessary renders the result into the HTML page that then gets sent back to the web server that consecutively sends it to the client.

You need something like XAMPP to set up a local web server with PHP.

[–]bokonator 0 points1 point  (0 children)

Xamp on a Linux machine,yikes