Re: More include issues

This is a discussion on Re: More include issues within the PHP General forums, part of the PHP Programming Forums category; > > I try not to bother the list and figure things out by myself as much as I > ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-06-2007
Jared Farrish
 
Posts: n/a
Default Re: More include issues

>
> I try not to bother the list and figure things out by myself as much as I
> can, but it's hard when I was "volunteered" to become the guinea pig to
> convert some of our apps from ColdFusion to PHP...especially when nobody I
> work with has ever touched PHP before. I have nobody to turn to except
> google/forums/this list.



I feel ya brotha! I think Stut might be having a bad day...

Coldfusion, MSSQL, Informix, PHP, oh my!

So once again, thank you, and thanks to everyone else that is helping this
> novice become more familiar with PHP.
>


Don't let the b*st*rds get you down, man.

A note about include paths: Unless you want to drive yourself totally batty,
always try to use absolute document paths when include/require'ing. I use a
simple constant that I stick at the top of every path I put together:

<code>
// The @ kills an error that would be produced
// if already defined
// Leave 'www/' empty if root path
// to current file is not a subdirectory
@define('INCLUDE_PATH_SUBDIRECTORY','www/');
@define('INCLUDE_PATH',
$_SERVER['DOCUMENT_ROOT'] .
(strrpos($_SERVER['DOCUMENT_ROOT'],'/') !==
(strlen($_SERVER['DOCUMENT_ROOT'])-1) ? '/' : '') .
INCLUDE_PATH_SUBDIRECTORY)
);
// Usage
// I recommend always using
// include_once and require_once
// unless you know for sure you
// need multiple includes for that
// file
include_once INCLUDE_PATH . 'Connections/conn.php';
</code>

This might output for INCLUDE_PATH:

"/inetpub/www/virtual/www_example_com/"

for example, which then becomes

"/inetpub/www/virtual/www_example_com/Connections/conn.php"

PHP will always know how to find that.

This works for me, but your usage or results may vary, and may not work on
all servers (IIS, for instance) or some Apache installations (I guess). Try
creating a test page and play around with it using echo and so on to see
what it outputs. You can contact me directly if the forum mungs it up on the
line-wrap.

Also try:

<code>
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
</code>

To see what server variables are available. Just remember, webroot (public)
and docroot (private) are different things.

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

Reply With Quote
  #2 (permalink)  
Old 06-07-2007
Robert Cummings
 
Posts: n/a
Default Re: [PHP] Re: More include issues

On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> >
> > I try not to bother the list and figure things out by myself as much as I
> > can, but it's hard when I was "volunteered" to become the guinea pig to
> > convert some of our apps from ColdFusion to PHP...especially when nobody I
> > work with has ever touched PHP before. I have nobody to turn to except
> > google/forums/this list.

>
>
> I feel ya brotha! I think Stut might be having a bad day...


Bad day?? Did you read the same posts I read?

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Reply With Quote
  #3 (permalink)  
Old 06-07-2007
Jared Farrish
 
Posts: n/a
Default Re: [PHP] Re: More include issues

On 6/6/07, Robert Cummings <robert@interjinn.com> wrote:
>
> On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > I feel ya brotha! I think Stut might be having a bad day...

>
> Bad day?? Did you read the same posts I read?
>
> Cheers,
> Rob.
>


Sure I did. Let's not take this too seriously, ok?

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

Reply With Quote
  #4 (permalink)  
Old 06-07-2007
Robert Cummings
 
Posts: n/a
Default Re: [PHP] Re: More include issues

On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> On 6/6/07, Robert Cummings <robert@interjinn.com> wrote:
> >
> > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > I feel ya brotha! I think Stut might be having a bad day...

> >
> > Bad day?? Did you read the same posts I read?

>
> Sure I did. Let's not take this too seriously, ok?


You forgot a winkie ;) :)

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
Reply With Quote
  #5 (permalink)  
Old 06-07-2007
Jared Farrish
 
Posts: n/a
Default Re: [PHP] Re: More include issues

On 6/6/07, Robert Cummings <robert@interjinn.com> wrote:
>
> On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
> > On 6/6/07, Robert Cummings <robert@interjinn.com> wrote:
> > >
> > > On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
> > > > I feel ya brotha! I think Stut might be having a bad day...
> > >
> > > Bad day?? Did you read the same posts I read?

> >
> > Sure I did. Let's not take this too seriously, ok?

>
> You forgot a winkie ;) :)
>
> Cheers,
> Rob.



Ach! YOU ARE SOOOO RIGHT!

Now I need a twinkie... ;)


--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

Reply With Quote
  #6 (permalink)  
Old 06-07-2007
Stut
 
Posts: n/a
Default Re: [PHP] Re: More include issues

Robert Cummings wrote:
> On Wed, 2007-06-06 at 20:26 -0500, Jared Farrish wrote:
>> On 6/6/07, Robert Cummings <robert@interjinn.com> wrote:
>>> On Wed, 2007-06-06 at 17:21 -0500, Jared Farrish wrote:
>>>> I feel ya brotha! I think Stut might be having a bad day...
>>> Bad day?? Did you read the same posts I read?

>> Sure I did. Let's not take this too seriously, ok?

>
> You forgot a winkie ;) :)


Hey, leave my winkie out of this!

-Stut
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0