![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
|
PHP Includes?
Well, I am using include statements on one of my projects. I am kind of racking my brain about something.
First off, the server I am using, I have no access to PHP.ini. I have set up under my root directory, a directory called includes, and there is where I am storing my include file called include.php. A few notes, I have seen things like include.inc or include.inc.php and so on and so forth. I am sure that you can make the file extention basically anything, .txt if you wish as well, as it is once the information is sent to the browser, it is then parsed on the server side and resent to the browser. So all you are saying is, take this and use it. anyway, the extention is unimportant to my question, sorry, but was sort of a fun theory to write. The question: when I am using my includes I am writting <? include 'include/include.php'; echo $whatever; ?> Now, let's say, my document that I want to call it from is in another directory. The code would have to look like this. <? include '../include/include.php'; echo $whatever; ?> Is there a way that I can construct my includes so that I can call them with one string from anywhere on the website. hardcoding them with the exact URL does not seem to work at all. Thoughts? Thanks Mike
__________________
Here's my latest project still in the works, and I need to get rid of this "frame" situation for real. www.prideofaustin.com |
|
|
|
|
|
#2 |
|
Professional Programmer
|
if you just call them from /includes/... the / brings you to the root of your directory tree, which in the server should be chrooted. so in both cases using [php]<?php include("/include/include.php"); echo $whatever; ?>[/php] will use the correct include file.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
Or if you have shell access you could link them to one include dir and call from there like you were before. That's if your running linux.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#4 |
|
Programmer
|
Thanks guys,
That pretty much confirmed my what I thought on this matter. The hosting I am using has not shell SSH access, they claim ummm.. security issues. I thought that was the reason we got away from telnet and into SSH to begin with, but then again, I just might be the fool on that one..LOL. Thanks again for the replies. Mike
__________________
Here's my latest project still in the works, and I need to get rid of this "frame" situation for real. www.prideofaustin.com |
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
Run this script from the same directory that the first script is in...
echo `pwd` . "/include/include.php"; You should be able to use what it prints out as your include statement's argument. This will be universal
__________________
|
|
|
|
|
|
#6 |
|
Expert Programmer
|
softlink directories... that always works too.. very effective I might add.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|