PHP code are shown in the page

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP code are shown in the page

Postby danielsega » 10. February 2014 18:44

I installed Xampp and ran a few test and every time i run a page with some PHP content with echo or print it display the code in the browser instead of printing the content.

Image

Here is the code:
<?php
echo "Hello World! <br>";
print "Hello World! <br>";
echo ("Hello World! <br>");
print ("Hello World! <br>");
echo "Hello " . "World!" . "<br>";
print "Hello " . "World!" . "<br>";
echo "Hello ", "World!" , "<br>";
?>
danielsega
 
Posts: 3
Joined: 10. February 2014 18:36
Operating System: Windows 7

Re: PHP code are shown in the page

Postby Altrea » 10. February 2014 18:49

Does your file have a .php or .html file extension?
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: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: PHP code are shown in the page

Postby danielsega » 10. February 2014 18:54

It has a .html extension.
danielsega
 
Posts: 3
Joined: 10. February 2014 18:36
Operating System: Windows 7

Re: PHP code are shown in the page

Postby Altrea » 10. February 2014 18:55

Then save it as .php file and everything will be okay.
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: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: PHP code are shown in the page

Postby siraguilar » 10. February 2014 18:58

be sure the services Apache and MySql are working and place the file with extension .php on c:\xampp\htdocs , mustly the apache service, the mySQL it sould be for databases

for example if you're file is called test.php and is located on c:\xampp\htdocs\examples\test.php you can call it on a browser like localhost\examples\test.php , good luck!
siraguilar
 
Posts: 1
Joined: 10. February 2014 18:51
Operating System: win7

Re: PHP code are shown in the page

Postby danielsega » 10. February 2014 19:54

I got it working with the php extension, is there any way for future reference to make it work as a html extension?
danielsega
 
Posts: 3
Joined: 10. February 2014 18:36
Operating System: Windows 7

Re: PHP code are shown in the page

Postby Nobbie » 10. February 2014 19:58

danielsega wrote:I got it working with the php extension, is there any way for future reference to make it work as a html extension?


There is no future reference to make it work as html extension, because

a) this is very a simple question of configuration in httpd.conf

b) it is NOT recommended anyway

Why do you think you need ALL HTML Documents parsed as PHP Documents?
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04

Re: PHP code are shown in the page

Postby Altrea » 11. February 2014 04:35

I am waiting for the day someone want to send every .jpg file through the php parser :roll:
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: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 150 guests