0

I have right now a .html document that I copy to new directories..

My question is : Is there a way to put text in the .html document between the <body> and </body> tags?

I'm sorry for this question, I mean with the short explaination, but I have searched everywhere.

Charles
  • 50,010
  • 13
  • 100
  • 141
Tommy
  • 657
  • 1
  • 10
  • 24

3 Answers3

1

On a web server running PHP, .PHP files are always processed through the PHP managed handler (decoder, sort of) and that INCLUDES a standard HTML processor. So, you can, without question, combine PHP and HTML in a single file. The key is proper placement of the scripted code and the HTML code.

An example of your "work" would be very useful here.

DevlshOne
  • 8,177
  • 1
  • 27
  • 36
1

yes you can using PHP fopen() read method , append whatever text you want using file_put_contents() , then save file to your server :

source: http://www.w3schools.com/php/php_file.asp , http://www.w3schools.com/php/func_filesystem_file_put_contents.asp

ProllyGeek
  • 14,987
  • 7
  • 49
  • 71
0

Not if is an .html document. ...Well, yes, but it requires altering server settings and it's really bad practice.

If you change it to a .php file. Then yes it's possible.

You would have something like this:

<body>
<?php 
      echo 'Hello World <br />';

      /*$content is something you would have defined earlier on 
        (it doesn't have to be called '$content' though) */
      echo $content;

?>

</body>
Rwd
  • 31,835
  • 6
  • 52
  • 69