
04-27-2006, 10:35 PM
|
|
Sexy Mariachi
|
|
Join Date: Nov 2004
Location: Mexico City
Posts: 731
|
|
PHP Import HTML external file
Hi, I have a problem that I can't solve, I've searched in google, in php documentation and nothing...
I have a PHP page, and I need to import plain HTML code into the page that contains the PHP code.
The file that contains the HTML is located in the same folder...
Please someone know how to do this?

|

04-27-2006, 10:39 PM
|
|
Newbie
|
|
Join Date: Sep 2003
Location: Pawtucket, RI USA
Posts: 23
|
|
Use somthing like...
Code:
$fd = fopen("file.html", r);
$content = fread($fd, filesize("file.html"));
fclose($fd);
echo $content;
Wherever you echo the $content your HTML file will be displayed. If you need further assistance feel free to PM me.
__________________
Jeffrey J. Dodge
RWJD.Com | [url=http://www.filehost.nu]FileHost.nu
|

04-27-2006, 10:53 PM
|
|
Sexy Mariachi
|
|
Join Date: Nov 2004
Location: Mexico City
Posts: 731
|
|
Thanks man, it works perfectly, Thanks!
|

04-27-2006, 11:12 PM
|
|
Web Hosting Master
|
|
Join Date: Aug 2002
Location: Canada
Posts: 644
|
|
Even simpler:
Code:
echo file_get_contents( "file.html" );
|

04-28-2006, 06:56 AM
|
|
Community Leader
|
|
Join Date: Oct 2002
Location: cognito
Posts: 17,318
|
|
Why not this?
Code:
include('file.html');
__________________
Have problems (don't we all)? Head over to the help desk
If at first you don't succeed, that's one data point.
|

04-28-2006, 09:44 AM
|
|
Newbie
|
|
Join Date: Feb 2006
Posts: 13
|
|
Quote:
|
Originally Posted by bear
Why not this?
Code:
include('file.html');
|
or
require('file.html');
if the file is mandatory and you want the loading to die if it's not found...
|

04-28-2006, 09:51 AM
|
|
Sexy Mariachi
|
|
Join Date: Nov 2004
Location: Mexico City
Posts: 731
|
|
Quote:
|
Originally Posted by El-Vino
or
require('file.html');
if the file is mandatory and you want the loading to die if it's not found...
|
Thanks to all of you guy's, Think I need to read again PHP for dummies...
Thanks 
|

04-28-2006, 10:07 AM
|
|
Web Hosting Evangelist
|
|
Join Date: Feb 2006
Location: Lancashire, UK
Posts: 472
|
|
i use require "file.php";
|

05-05-2006, 09:41 AM
|
|
Newbie
|
|
Join Date: May 2006
Posts: 20
|
|
This is like what I have ben looking to do, only is there a way to do this if there are meany html files, and diffrent names where you dont know the names?
odd ??? I know but if anyone could help
|

05-05-2006, 10:32 AM
|
|
Newbie
|
|
Join Date: Apr 2006
Posts: 5
|
|
You can always use your include in a loop, with a variable.
Do something like open the directory and loop through all of the files. For each file, if they match a given string template, include that file.
Should be pretty simple.
|

05-05-2006, 10:50 AM
|
|
Web Hosting Guru
|
|
Join Date: Nov 2003
Posts: 297
|
|
no need for a loop...
PHP Code:
<? if ((isset($_GET['p'])) && (isfile($_GET['p'].'.html'))) include($_GET['p'].'.html'); else include('default.html'); ?>
you would call pages with index.php?p=mypage
|

05-05-2006, 11:20 AM
|
|
Newbie
|
|
Join Date: May 2006
Posts: 20
|
|
I am a little new to php, could you explain how your code would work nnormal?
just looking at it, it looks like this still needs a file that you know the name of the file. also would this alow me to do this 10+ times in one page, and could I put this php script in a html page?
sorry for all the ????, like I said I am a little new to php. thanks
|

05-05-2006, 11:22 AM
|
|
Newbie
|
|
Join Date: Apr 2006
Posts: 5
|
|
Absolutely. I just thought that atomicshockwave was talking about including multiple HTML files with unknown names into one PHP script.
|

05-05-2006, 11:25 AM
|
|
Web Hosting Guru
|
|
Join Date: Nov 2003
Posts: 297
|
|
it wouldnt put multiple files in for that you may need a loop. are you trying to include each file from a directory or something?
PHP Code:
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
include($file);
}
}
closedir($handle);
}
?>
|

05-05-2006, 11:41 AM
|
|
Newbie
|
|
Join Date: May 2006
Posts: 20
|
|
I need to have dhtml popup window for each html file in a folder on my site, and I need the script to add the window script, because files are added and removed evry day, now my plain is that in the html files would be the window script, and the php code would find the files and run the code in the index.html file (my homepage where I need the windows.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|