My php code is not executed when I access the root directory with
http://localhost:8080/sample.html
The code I want to run is:
<?php phpinfo(); ?>
and I tried also the following:
Could it be that some firefox extensions are blocking php-execution?
All I get is the php code exactly like I wrote it.
No extensions can interfere with execution of php because it is executed at the server end, not the client end.
The php code is not executed because your file's extension is html and the WAMP server does not process .html
files.
Change the extension to sample. php and then it will work
You're trying to execute PHP in an ".html" file. You have to edit the PHP handler in the apache config to make it process whatever file extension you want it to. Look for "AddType application/x-httpd-php .php" in your Apache configuration file (somewhere like 'wamp/apache/conf/httpd.conf') then just add " .html" after ".php". The line should look like this now:
AddType application/x-httpd-php .php .html
PHP should now execute any code it finds in files with ".php" and ".html" extensions.
Edit: Or as someone suggested above, just rename your file "sample.php" and it'll be processed.
It might help somebody. Changing the tags from
<?
to
<?php
did the trick for me on my WAMP server.
If you're seeing literally the string
<?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 filename ends with .php exactly. If windows adds a .txt or other crap when you save the file to the end, apache will not know to have php process it.
重新启动所有服务并确保 WAMP 服务器图标为绿色,如果不是,则重新启动 wamp 服务器或重新安装它。然后检查本地主机。
I got here by google for the same symtoms.
In my case, it was just the Windows Explorer wich was hiding file extensions.
A good trap for casual users of Windows, like me.
So instead of having my file named index.php, I had actually index.php.txt.
I fixed the extension display by using this procedure : http://kb.winzip.com/kb/entry/26/
The clue was : I had no IDE icon on my php file.
I don't know if my answer really helps, 5 years after the initial question...
Yeah, I too faced the same problem. I solved it by changing the file extensions generally, we save the file with ".php" extension but the computer may get stored in the ".php.txt" extension. So change it by clicking on "view" which is present at the top toolbar of file manager and then mark select to the checkbox "File New Extension", by doing this it will show different extensions to your stored files and accordingly change the extension.
hope, it might solved your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.