workaround for includes?

This is a discussion on "workaround for includes?" within the PHP Forum section. This forum, and the thread "workaround for includes? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 13th, 2007, 20:28
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
workaround for includes?

if i want to include something relative to the website root
how would i do this?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote

  #2 (permalink)  
Old Sep 13th, 2007, 20:58
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: workaround for includes?

RTFM alex!

Quote:
<?php

$times = substr_count($_SERVER['PHP_SELF'],"/");
$rootaccess = "";
$i = 1;

while ($i < $times) {
$rootaccess .= "../";
$i++;
}
include ($rootaccess."foo/bar.php");

?>
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #3 (permalink)  
Old Sep 14th, 2007, 06:38
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: workaround for includes?

PHP: Select all

<?php
include(preg_replace("/(\/[\w]+)/i","../",$t)."foo/bar.php");
?>
Reply With Quote
  #4 (permalink)  
Old Sep 15th, 2007, 05:47
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: workaround for includes?

You could even use $_SERVER[DOCUMENT_ROOT]
Reply With Quote
  #5 (permalink)  
Old Sep 15th, 2007, 11:27
alexgeek's Avatar
Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,771
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: workaround for includes?

doesn't that go to like:
C:\location\of\web\files
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A workaround for a problem you might not know you have...yet Skelbo Web Page Design 1 Jul 13th, 2007 18:00
IE workaround? jwalker80 Web Page Design 1 Jul 12th, 2007 16:44
xsl includes sconard Other Programming Languages 0 Aug 24th, 2006 13:11
PHP Includes lesleindotcom PHP Forum 3 May 31st, 2006 20:54
PHP Includes daygon PHP Forum 5 Mar 16th, 2006 01:59


All times are GMT. The time now is 22:33.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43