PDA

View Full Version : PHP include - how to?


ahosang
01-14-2003, 03:41 PM
OK experts, help a PHP-illiterate out.
I don't know any PHP, nor am I learning it, but I need this to help someone else out regarding a counter. They are using iframe right now to show the counter. That's gotta be stupid, right?
if the PHP file is:
http://members.ivwnet.com/curious@ivwnet.com/YUMYUM/PASTA.php

That returns text/html by the way. How do you do an include?
<? php include("http://members.ivwnet.com/curious@ivwnet.com/YUMYUM/PASTA.php") ?>

or something like that???

mordred
01-14-2003, 04:08 PM
That's correct, but won't work on Windows necessarily due to the fact that URL wrappers don't work on that platform unless you use PHP 4.3.

ahosang
01-14-2003, 05:41 PM
Windows??
Server-side only needed. What's the most backward-compatible statement?
I mean the PASTA.php returns text/html, so do I need an echo function as well as include? I don't know what version of php ivwnet.com uses, but that's what this person's site is hosted by.

mordred
01-14-2003, 07:12 PM
include("file.ext");

should be very backwards-compatible. I didn't understand your question about echoing the content - that depends on the nature of the script, i.e. what you are doing with this included file. Having said this, it's not very clear to me where the actual problem lies... perhaps you can elaborate a little bit more? I mean, do you get any error message?

ahosang
01-14-2003, 08:18 PM
No error reported by me. That's the thing. I'm not using php(so I'm not the one testing this), never have, maybe never will. I'm just trying to pass on the code to someone so they don't have to use ilayers and iframes.
step-by-step:
1) PASTA.php has a final statement that goes:
echo $contents

$contents is just an HTML string - <img src="counter.gif"> for example

2) To insert this HTML string into a page, say test.php, is this the syntax?
test.php:
<html>
<body>
Test page to include an image via PHP<br>
<? php include("http://members.ivwnet.com/curious@ivwnet.com/YUMYUM/PASTA.php") ?>
</body>
</html>

Will that give this output to the browser?

<html>
<body>
Test page to include an image via PHP<br>
<img src="counter.gif">
</body>
</html>

mordred
01-14-2003, 08:55 PM
Yes, the example you gave should work as intended.

ahosang
01-14-2003, 09:15 PM
thanks !