Page 1 of 1

PHP code are shown in the page

PostPosted: 10. February 2014 18:44
by danielsega
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>";
?>

Re: PHP code are shown in the page

PostPosted: 10. February 2014 18:49
by Altrea
Does your file have a .php or .html file extension?

Re: PHP code are shown in the page

PostPosted: 10. February 2014 18:54
by danielsega
It has a .html extension.

Re: PHP code are shown in the page

PostPosted: 10. February 2014 18:55
by Altrea
Then save it as .php file and everything will be okay.

Re: PHP code are shown in the page

PostPosted: 10. February 2014 18:58
by siraguilar
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!

Re: PHP code are shown in the page

PostPosted: 10. February 2014 19:54
by danielsega
I got it working with the php extension, is there any way for future reference to make it work as a html extension?

Re: PHP code are shown in the page

PostPosted: 10. February 2014 19:58
by Nobbie
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?

Re: PHP code are shown in the page

PostPosted: 11. February 2014 04:35
by Altrea
I am waiting for the day someone want to send every .jpg file through the php parser :roll: