PHP rendering as text

Problem:
basic PHP file rendering as text in browser
.php file is stored in htdocs/test_files
these are test files I’m using to learn PHP using basic commands such as “echo”

Installation:
MAMP. Confirmed servers are working. Can view phpinfo. Apache root is Applications/MAMP/htdocs

Other info:
Also downloaded WordPress files into htdocs. This installation was successful and I can view those files in the browser. Not sure if this is causing some sort of problem.

I’m trying to execute basic PHP code in a Komodo Edit. When I use browser preview nothing happens. When opening the file in a browser the code renders as plain text. The file is stored under htdocs. It appears that the MAMP installation was successful. (lights are green

I’ve watched several tutorials on installing PHP, but nothing seems to cover this issue.

Have you uploaded the PHP file to the server it will be hosted on, then access the server url in your browser.

Thanks for the reply.

As I understand it, Apache is the server. So if you upload a .php file to the Apache root, which is Applications/MAMP/htdocs/… then you have uploaded it to the server. Is this not the case?

I found the answer. To those new to MAMP/PHP, the servers and databases were functioning correctly. In order to view the file in a browser I needed to visit http://localhost:8888/file_name in my browser. I believe this accessed the server (the localhost:8888 part) for the file rather than trying to view the file directly in a browser (for example, right clicking on the file and viewing in Safari - this didn’t work).

The steps listed here put my on the right path:

http://sawmac.com/mamp/

Good Luck.

Sponsor our Newsletter | Privacy Policy | Terms of Service