Page 1 of 1

String PHP doesn't work inside HTML file

PostPosted: 28. January 2014 20:26
by rtc_brz
Hi,
I have the following problem, if someone can help I will appreciate.
HTML code: (testphp.html)
<html>
<head>Test info PHP</head>
<body>
<?php
phpinfo();
?>
</body>
</html>

Result : Test info PHP (only)

Something PHP code (testphp.php)
<?php
phpinfo();
?>

Result: all info about PHP instaled on XAMPP

Whats worng?
Tks

Re: String PHP doesn't work inside HTML file

PostPosted: 28. January 2014 21:00
by russsaidwords
I believe what's happening is that Apache doesn't recognize the .html file extension as belonging on the end of a file that needs to be sent through PHP. A quick check is to replace the testphp.html filename with testphp.php

Re: String PHP doesn't work inside HTML file

PostPosted: 28. January 2014 21:48
by rtc_brz
Thanks for the answer but Apache works good with html files, the only problem is that it don't process the string php inside html code, all others (java, js) strings are ok. When run a php file works fine, html file too but, string php inside html file( eg. <?php include("myfile.php") ?>) doens't work.

Re: String PHP doesn't work inside HTML file

PostPosted: 28. January 2014 22:00
by Altrea
russsaidwords already said everything important. By default Apache don't send .html files through the php interpreter.
And if you are wondering why js code is working, think about what the difference is between js and php.

Re: String PHP doesn't work inside HTML file

PostPosted: 29. January 2014 01:42
by rtc_brz
russsaidwords and Altrea, sorry for ignorance, especially in not understanding the russsaidwords, really just changing the extension from html to php file without changing the content, worked perfectly. Thanks to you guys for the help.