Wamp Server does not execute php code

My PHP code is not executing when I access the root directory with

http://localhost:8080/sample.html 

The code I want to run is:

 <?php phpinfo(); ?> 

and I also tried the following:

  • Restarted all services several times, including hosting Wamp Server online.
  • Change the listening port in httpd.conf to 8080 and configure Skype to accept ports 80 and 443.

Could it be that some Firefox extensions block php execution?

All I get is the php code as I wrote it.

+4
source share
6 answers

You are trying to execute PHP in a .html file. You must edit the PHP handler in the apache configuration so that it handles any file extension you want. Find “AddType / x-httpd-php.php application” in your Apache configuration file (somewhere like “wamp / apache / conf / httpd.conf”), and then just add “.html” after “.php”. Now the line should look like this:

 AddType application/x-httpd-php .php .html 

Now PHP should execute any code that it finds in files with the .php and .html extensions.

Edit: or as someone suggested above, just rename the file “sample.php” and it will be processed.

+5
source

No extensions can interfere with php, as they run on the server side, not on the client side.

PHP code is not executed because the html file extension and the WAMP server do not process .html files.

Change the extension to a pattern. php and then it will work

+4
source

It might help someone. Change tags from

 <? 

to

 <?php 

did the trick for me on my WAMP server.

+2
source

If you see literally a line

 <?php phpinfo(); ?> 

Open the httpd.conf file and uncomment the line

 LoadModule php5_module "C:/PROGRA~1/BITNAM~1/php/php5apache2_2.dll" 

Also make sure the file name ends with .php for sure. If adding a file to the end of the window adds .txt or other crap, apache will not know that php is processing it.

0
source

restart all services and make sure that the WAMP server icon is green if it does not restart the Wamp server or does not restart it. Then check the local host.

0
source

I got google here for the same symmetries.

In my case, it was just Windows Explorer, which hid file extensions.

A good trap for casual Windows users like me.

So instead of having a file called index.php, I had index.php.txt.

I installed the extension using this procedure: http://kb.winzip.com/kb/entry/26/

The key was: I did not have an IDE icon in my php file.

I don’t know if my answer really helps, 5 years after the initial question ...

0
source

Source: https://habr.com/ru/post/1412572/


All Articles