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,943
  • 13
  • 104
  • 142
Tommy
  • 667
  • 1
  • 10
  • 25

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,357
  • 1
  • 29
  • 37
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
  • 15,517
  • 9
  • 53
  • 72
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
  • 34,180
  • 6
  • 64
  • 78