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.

9
  • 2
    Sure is, open the document, identify the body section, inject your changes, save the file. Where's your question? Commented Dec 3, 2013 at 12:50
  • Read the file, parse it with a DOM parser, add the data and then save the result. Commented Dec 3, 2013 at 12:51
  • @MikeB how to identify there's my problem ^^ Commented Dec 3, 2013 at 12:51
  • What kind of proof have you done? Commented Dec 3, 2013 at 12:51
  • 1
    stackoverflow.com/questions/9604793/… Commented Dec 3, 2013 at 12:52

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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.

4 Comments

I have a .html file with all the html tags, and i copy it to a new folder, and the file in the new folder i want to add "This is Text"
Do you know WHERE you want "This is Text" to appear on the rendered page (when viewing in the browser)?
Inside the <body> Like this <html><head></head><body>This is Text</body></html>
Then go for it! You won't break anything.
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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.