PHP Code Not Executing - All PHP displayed on browser

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

PHP Code Not Executing - All PHP displayed on browser

Postby bbmixer » 15. December 2014 18:23

Installed XAMPP 1.8.3-5 on my MAC OS X. Everything seems to be working fine (i.e. when I enter "http://localhost/xampp/" in browser, it takes me to XAMPP welcome page.)

I am trying to write PHP code in my text editor (tried two different ones -TextWrangler & Tincta) and the PHP code is not executing. When I run the code it simply displays all the code in the browser (Safari), including all brackets….every line of code is simply displayed exactly as I write it in the text editor.(ex. <?php echo "Hello"; ?> - will be displayed exactly like this in the browser.)….and I am saving with as a .php file.

All .html & .css & js files work just fine…..the only code that will not run is PHP.
bbmixer
 
Posts: 4
Joined: 15. December 2014 17:57
Operating System: OS X

Re: PHP Code Not Executing - All PHP displayed on browser

Postby Altrea » 15. December 2014 19:55

How did you access your PHP files?
which address does your browser show?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: PHP Code Not Executing - All PHP displayed on browser

Postby bbmixer » 16. December 2014 07:24

Sorry for the delayed reply….

Here is how the address is displayed in the browser:

file:///Applications/XAMPP/xamppfiles/htdocs/connect.php

One other thing, I just tried adding a php echo tag within one of my html scripts…and when I open the page in the browser, nothing from the php script is displayed.

Seems the system is simply not processing any kind of php code.
bbmixer
 
Posts: 4
Joined: 15. December 2014 17:57
Operating System: OS X

Re: PHP Code Not Executing - All PHP displayed on browser

Postby Nobbie » 16. December 2014 12:01

bbmixer wrote:file:///Applications/XAMPP/xamppfiles/htdocs/connect.php


What is wrong, that does not work. You *MUST NOT* double click connect.php in an File Explorer or similar, you MUST apply a valid URL to the browser, in this case it is http://localhost/connect.php (you may simply click on that link).

bbmixer wrote:Seems the system is simply not processing any kind of php code.



Of course not, because with file:// protocoll the browser simply opens the file for reading directly, but what you need is Apache(!!!) to open the file and send it to the browser. And for Apache you need the protocoll http and the hostname (i.e. Servername) is "localhost", when it is running locally (on the same PC as the client i.e. the browser). Keep in mind, that usually you need TWO PCs for that scenario, a Server and a Client. In this special case the Server is actually the same hardware as the client, but you need to address the Server in order to trigger Apache.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: PHP Code Not Executing - All PHP displayed on browser

Postby bbmixer » 16. December 2014 14:29

:oops: thats was it !!

This is all new for me….Thank you for taking the time to reply :D
bbmixer
 
Posts: 4
Joined: 15. December 2014 17:57
Operating System: OS X


Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 9 guests