简体   繁体   中英

WAMP and XAMPP Show PHP Instead of Running It

I understand that this is a problem with many others and that this question has been asked before, but no matter what, nothing is working . In other situations, they get it eventually, but I've tried different versions of XAMPP and WAMP constantly and nothing works. Here's some things that I do know:

  • The documents I'm trying to run are in the "www" folder (WAMP) and "htdocs" folder (XAMPP) . I'm using the default "test" pages that each program includes. This also means that they're not using the short PHP tags and they are PHP file types.

  • With WAMP, the icon turns green . I've had a problem in the past where it stayed yellow/orange, but I got it to go green. I also tried putting WAMP online, but that didn't make a difference.

  • Port 80 is not used . I changed Skype's settings to not use port 80. I also changed Apache's listening port to 81 temporarily , but no change.

  • Phpinfo() and localhost work on WAMP and XAMPP .

  • System Specs: Windows 7 64-Bit. (I've tried both 32-bit and 64-bit WAMP)

  • I tried it on my dad's laptop and that didn't work (Windows 7 32-bit) . So it must not be something wrong with my computer?

  • Typing localhost/testmysql.php in the address bar shows this: “ mysql_connet()”警告消息。 I'm not sure what that means, but since a default file is named "testmysql.php" in the "www" folder, this is odd.

If you have any questions, just leave a comment. I'm sure that if this problem gets solved, then any situation that anyone else has can look here and find a solution. Thanks for your help in advance.

Well, I didn't think I'd be able to come up with a solution, but this "kinda" works. Here's the thing:

I'm using XAMPP now, and I create a PHP file of my own (with <?php echo "It works!"; ?> ) and put it in the "htdocs" folder. When I double click on the file, it shows raw PHP code. However, if I type " localhost/test.php ", it works fine.

Now I'm not sure if the same thing works with WAMP because I uninstalled that before finding a solution. I find it a bit frustrating that I have to type location of the file in the address bar to get it started, but once I do, the links to other pages work fine.

I hope you found this useful, guys. If you have a solution to allow the PHP to run when double clicking on the file in the "htdocs" folder, go ahead, I don't mind changing correct answers :)

我正在使用Visual-AMP,就像IIS,可以操作右键。

I don't think you will be able to double click a php file to make it run. The point of installing a server is to run the file on the server. PHP is server side and will never run correctly as a local file. You must start with the web address "localhost" to run the file on the server.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM