0

How I can write html code (not executable) to a file by using php filesystems. For example I want to put my html page template which includes DOCTYPE, HEADER, BODY BLOCK, FOOTER etc.

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Ahmad Raza
  • 59
  • 5

2 Answers2

0
<html>
 <head>
  <title>PHP Test</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'; ?> 
 </body>
</html>

Your first PHP-enabled page

Read more

Community
  • 1
  • 1
YesItsMe
  • 1,709
  • 16
  • 32
0

as i got you question

save file index.php instead off index.html.

inside you can use

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
</body>
</html>

when ever you need to write a php(inside body)

use

<?php
//php code goes here
?>

example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
//php code goes here
?>
</body>
</html>

php will work when file extension is .php. if file extension is .html browser will not recognize your PHP code and it shows complete code on browser

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85