Difference between revisions of "Embed PHP into HTML"

From Conservapedia
Jump to navigation Jump to search
(to configure your Apache server)
m (more computer tips)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
−
To '''embed PHP into HTML''', simply enclose your PHP code in <nowiki><?PHP</nowiki> and <nowiki>?></nowiki> tags like this:  
+
To '''embed PHP into HTML''', simply enclose your PHP code in the same sort of tags used for regular PHP code, like this:  
 
  <?PHP echo "Hello, world!"; ?>
 
  <?PHP echo "Hello, world!"; ?>
 
You may have to configure your [[Apache server]] (or have your system administrator do it for you). Include this line in your server's [[httpd.conf]] file:
 
You may have to configure your [[Apache server]] (or have your system administrator do it for you). Include this line in your server's [[httpd.conf]] file:
  
−
  [[AddType]] application/x-httpd-php .html .htm
+
  AddType application/x-httpd-php .html .htm
 +
 
 +
Some servers may require you to put this line in your .htaccess file (in the directory which has the HTML file):
 +
 
 +
AddHandler application/x-httpd-php52 .php .htm .html
 +
[[Category:Computer tips]]

Latest revision as of 13:29, August 5, 2011

To embed PHP into HTML, simply enclose your PHP code in the same sort of tags used for regular PHP code, like this:

<?PHP echo "Hello, world!"; ?>

You may have to configure your Apache server (or have your system administrator do it for you). Include this line in your server's httpd.conf file:

AddType application/x-httpd-php .html .htm

Some servers may require you to put this line in your .htaccess file (in the directory which has the HTML file):

AddHandler application/x-httpd-php52 .php .htm .html