PDA

View Full Version : calling includes


eggz
04-25-2003, 03:40 PM
Sorry if this is the wrong place to post this, or my question isn't too clear - im a bit of a n00b when it comes to PHP - bring on WYSIWIG HTML and i'd be fine...! :p

Basically I'm trying to include a file (gallery latest photos FYI) from my forum home. I've created a template, forumhome_latestphotos and have placed the code for it in forum home. The table section that i've placed in the template so far shows up so I know i haven't messed that bit up :classic:

My question:

How can i get

include("thumbs.php";

to parse? Do I need to edit index.php or can i just use the phpinclude template?

TYIA
Ollie

filburt1
04-25-2003, 04:48 PM
You can just use phpinclude.

eggz
04-25-2003, 05:22 PM
So if i wanted to make it so that wherever i put $getlphotos, it includes thumbs.php in that area, would i use something like

$getlphotos=<?php include("thumbs.php") ?>

or would i need to use eval? if i do - how?!?!?! lol

or would i have to use another method?

Ollie

eggz
04-25-2003, 07:33 PM
ne1?

TIA
Ollie

Kriek
04-25-2003, 07:53 PM
$getlphotos ='thumbs.php';
include('$getlphotos');

eggz
04-25-2003, 08:17 PM
Thanks Kriek,

Was almost going to sleep there :P

Is that meant to go in PHP Incl.?

If i put it in there i get parse errors at top of page...

so should it go in index.php?

If so, where abouts?

Thanks
Ollie

eggz
04-25-2003, 09:17 PM
Sorted it!

Used ob

Thanks neway!

Ollie

Dean C
04-26-2003, 12:05 PM
Also make sure you use your parentheses (the brackets) correctly.

E.g.


include("thefilename.txt");


- miSt

gmarik
04-26-2003, 01:18 PM
What do you think about this? It must work on Windows as well as on UNIX:

function DeWin($path)
{
if(substr($path,1,1)==':')
$path=substr($path,2);
return str_replace('//','/',str_replace('\','/',$path));
}

function document_root()
{
global $HTTP_SERVER_VARS;
$s=&$HTTP_SERVER_VARS;

if(isset($s['CMDLINE'])) return false;

$full=DeWin($s['PATH_TRANSLATED']);
$i_am=DeWin($s['PHP_SELF']);
if(substr($full,-strlen($i_am))==$i_am)
return substr($s['PATH_TRANSLATED'],0,strlen($s['PATH_TRANSLATED'])-strlen($i_am));

return getenv('DOCUMENT_ROOT');
}