Jump to content


Photo

PHP include site relative


  • Please log in to reply
4 replies to this topic

#1 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 13 August 2006 - 05:01 PM

I have browsed the internet and have learnt that you cannot use PHP includes with site relative linking. I was wondering if there was any alternative way where I could use PHP to include a file using a site relative link to define the include file. As far as I know there isn't, and a google search hasn't shown an alternative. I can't use an SHTML file for the include as I have important PHP scripts on the page. Does anyone know of any sort of alternative or solution?

Many thanks to anyone who can help.

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 13 August 2006 - 05:14 PM

If by relative linking u mean not the full url, yes you can

include("file.php");
Tell me the problem, I will try tell you the solution

#3 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 13 August 2006 - 05:34 PM

No, I don't mean not the full URL. I mean site relative as in: <? include("/page.php"); ?>

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 13 August 2006 - 06:06 PM

ahh
you can use docroot

<?php
include($_SERVER['DOCUMENT_ROOT']."/file.php");
?>

Tell me the problem, I will try tell you the solution

#5 bertieboy_93

bertieboy_93
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 13 August 2006 - 06:13 PM

Thanks for the solution, it worked great!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users