#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    11
    Rep Power
    0
    How can I put HTML code that is in a file
    PHP have any funtion or I have to do it???

    PS: Sorry my bad english

    ------------------
    {C00L|Z3R0} on irc.ptnet.org
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    require ("blah.html");

    or

    include ("blah.htm");
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    I don't think this is possible, but is there any way to include only part of a file? For example, including an HTML file in a PHP file and including just the stuff between <body> and </body>?
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    21
    Rep Power
    0
    Sure...but you have to parse the file a bit...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $file = file("yourfile.html");

    for($x = 0; $x < count($file); $x++) {
    if(strstr("<body>", $file[$x]))
    $in_body = 1;
    if($in_body)
    echo $file[$x];
    if(strstr("</body>", $file[$x]))
    $in_body = 0;
    }
    [/code]

    Thats one of many ways to do it...there are better ways but I couldn't come up with any off the top of my head



    ------------------
    - theFinn
    http://www.totalgeek.org
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    Thanks! That worked very well. I just made two changes:

    In the if statements, the / needed to be escaped with , and the text to look for and the $file[$x] were reversed. So those lines look like:

    if(strstr( $file[$x], "<BODY>"))

    if(strstr( $file[$x], "</BODY>"))

Similar Threads

  1. header/footer in html (each page) just like word file
    By nihaarika2002 in forum HTML Programming
    Replies: 4
    Last Post: April 12th, 2004, 01:51 PM
  2. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  3. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 07:06 AM
  4. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 08:42 PM
  5. Replies: 1
    Last Post: February 5th, 2004, 10:38 AM

IMN logo majestic logo threadwatch logo seochat tools logo