-1

As per the instruction i have successfully installed apache 2.2 web server Also php 5.3.5 has also been successfully installed .. As per the instruction i created a php file and checked whether the php installation was successful ,it also worked ..

The php file i created as per the instruction:

 <?php
   phpinfo();
 ?>

It worked.All is good till here...But whenever i embbed php script in html file and try to excess tht file ,the script in the HTML file doesnt run ..

for e.g

  <html>
    <body>
        <?php

              echo "hlw everyone";

          ?>
     </body>
 </html>

Saving the file and trying to access it doesnot output "hlw everyone " in the document..Can someone let me knw why is this happening..

Maizere Pathak.Nepal
  • 2,383
  • 3
  • 27
  • 41

2 Answers2

0

You have to configure your Apache server to execute PHP code inside a HTML page

Try it:-

AddType application/x-httpd-php .html

and save it as .htaccess in the same folder as your .html file. And that should do it.

Go through this link. for detailed answer.

Note: Answer inspired by jmeas

Community
  • 1
  • 1
Bit_hunter
  • 789
  • 2
  • 8
  • 25
0

If you follow the advice of configuring your web server so that HTML files are passed to the PHP parser by default, that means every HTML file whether it contains PHP or not will be sent to PHP's parser. For a pure HTML file that's a waste of time. If you have a large number of HTML files that could impact performance.

On the other hand, the .htm or .html extension hides from visitors to your site that the page they are viewing may be the result of the file containing some PHP code. So, the .htm or .html extension provides a bit of "security by obscurity".

Renaming those HTML files that contain some PHP code with a .php extension may be a better choice in terms of speed and convenience.

slevy1
  • 3,797
  • 2
  • 27
  • 33