1

I have parsed PHP within my HTML document and have saved it to the root directory of my wamp by the name helloworld and by the extension HTML but whenever I access that web page through my web browser using the URL:

http://localhost/helloworld.html.....

my browser just shows a blank screen.Why is this happening plz help? (Please note that I always keep the HTTP server and the database server of my wamp running while I do this)

always-a-learner
  • 3,671
  • 10
  • 41
  • 81

3 Answers3

2

I think You simply missing the point:

To run a PHP file with WAMP you need to follow this basic step:


  1. Now Simply Create your project folder. i.e test_project WAMP/WWW/test_project

  2. Now Put Your helloworld.html file inside the project folder and change the extension to .php

  3. Now to open this helloworld.php you can go to your browser and type localhost/test_project/helloworld.php. This will automatically run your file.

And if you are keen to use it this way then you should do this. you can use PHP code inside .html files, But you need to config the web server. In Apache you can config like this:

# Interpret both .php & .html as PHP:
AddHandler php5-script .php .html

As reference look this answer here

always-a-learner
  • 3,671
  • 10
  • 41
  • 81
-1

To execute PHP scripts, you have to rename your file to .PHP extension and make sure it's run by a webserver.

  • 1
    If you want to parse PHP BUT keep the HTML extension, you have to do some rewrite rules on your webserver config, like .htaccess on Apache or your nginx config – Mathis Schülingkamp Jul 13 '17 at 11:47
-1

If you want to have a http://anyurl/page.html that parses PHP-Code you can add a Rewrite Rule (Mod Rewrite) like this in your .htaccess-File:

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]

Keep in Mind that the Files have to be stored as .php-Files and that these are only camouflaged PHP-Files and displayed as HTML-Files in your Browser.

always-a-learner
  • 3,671
  • 10
  • 41
  • 81
Bernhard
  • 1,852
  • 11
  • 19