Science, Tech, Math Computer Science PHP Code Showing Instead of Running Why does PHP code show as text instead of executing? Share Flipboard Email Print Computer Science PHP Programming Language Basics Tutorials MySQL Commands Perl Programming Language Python Programming Java Programming JavaScript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More by Angela Bradley Updated August 21, 2017 You've written your first PHP program, but when you go to run it, all you see in your browser is the code—the program doesn't actually run. When this happens, the most common cause is that you are trying to run PHP somewhere that doesn't support PHP.Running PHP on a Web ServerIf you are running PHP on a web server, make sure you have a host that is set up to run PHP. Although most web servers support PHP nowadays, if you aren't sure, a quick test can give you the answer. In any text editor, create a new file and type: phpinfo() ; ?>Save the file as test.php and upload it to the root folder of your server. (Windows users make sure to display all file extensions.) Open a browser on your computer and enter the URL of your file in the format: http://nameofyourserver/test.phpClick Enter. If the web server supports PHP, you should see a screen filled with information and a PHP logo at the top. If you don't see it, your server doesn't have PHP or PHP is not started properly. Email the web server to ask about your options.Running PHP on a Windows ComputerIf you are running your PHP script on a Windows computer, you need to manually install PHP. If you haven't already done so, your PHP code won't execute. Instructions for the installation process, versions and the system requirements are listed at the PHP website. After it is installed, your browser should run your PHP programs directly from your computer. Running PHP on a Mac ComputerIf you are on an Apple, you already have Apache and PHP on your computer. You just need to activate it to get things working. Activate Apache in the Terminal, which is located in the Utilities folder, by using the following command instructions.Start Apache web sharing: sudo apachect1 startStop Apache web sharing: sudo apachet1 stopFind the Apache version: httpd -vIn macOS Sierra, the Apache version is Apache 2.4.23.After you start Apache, open a browser and enter: http://localhostThis should display "It Works!" in the browser window. If not, troubleshoot Apache by running its config file in Terminal. apachect1 configtest The configuration test may give some indications why the PHP isn't executing. citecite this article Format mla apa chicago Your Citation Bradley, Angela. "PHP Code Showing Instead of Running." ThoughtCo, Aug. 21, 2017, thoughtco.com/php-code-showing-instead-of-running-2694209. Bradley, Angela. (2017, August 21). PHP Code Showing Instead of Running. Retrieved from https://www.thoughtco.com/php-code-showing-instead-of-running-2694209 Bradley, Angela. "PHP Code Showing Instead of Running." ThoughtCo. https://www.thoughtco.com/php-code-showing-instead-of-running-2694209 (accessed April 23, 2018). copy citation Continue Reading