NYCPHP Meetup

NYPHP.org

[nycphp-talk] Include File Access

Chris Snyder csnyder at chxo.com
Mon Sep 8 15:01:35 EDT 2003


Obviously a quick solution would be to just use the absolute path to the 
util.php file... or am I missing something?

If you had a number of such paths that you needed to set (or other 
vlaues that you wanted to make available to every script in the 
application), you could define() them as constants in a config.php file:

config.php:

    <?php
    // constants for my application
    define ( 'APP_UTIL', '/path/to/www/inc/util.php' );
    ... other stuff  

script.php:

    <?php
    require_once('/path/to/config.php');
    include(APP_UTIL);

You sill have to change all your files if the path to the config.php 
file changes, of course.

     csnyder

Rudy Gamberini wrote:

>Thanks for the info.  Before posting this question I reviewed the
>Fundamentals topic and wasn't able to find a solution.  I try to stay
>current with this list and feel like I taking a college course that requires
>considerable reading every night.
>
>If I figure out an approach to my issue you can be sure I will offer it up
>to the Fundamentals topic.  For now I'll do some trail blazing of my own.
>
>Rudy
>
>
>-----Original Message-----
>From: talk-bounces at lists.nyphp.org
>[mailto:talk-bounces at lists.nyphp.org]On Behalf Of Michael Southwell
>Sent: Monday, September 08, 2003 2:28 PM
>To: NYPHP Talk
>Subject: Re: [nycphp-talk] Include File Access
>
>
>This is precisely what the recent Fundamentals topic was.  Within a week we
>should have a beta of "best [or at least common] practices"--no help to you
>now, I realize--except that you have just contributed yet another element
>to the complexity of the example.
>
>
>At 02:02 PM 9/8/2003, you wrote:
>  
>
>>Give the following web site file architecture:
>>
>>           Root
>>              |
>>     -----------------------------
>>     |                 |              |          |
>>page1         page2      page3    inc
>>
>>I place my util.php file in the "inc" directory.  As it turns out I need
>>to access this file from the Root directory as well as the various page
>>directories.  While I can place the relative path to the include file
>>with   { include "./inc/util.php"  } for the Root and   { include
>>"../inc/util.php" }  for the sub-pages, this causes problems with my
>>common code.
>>
>>I construct my pages with common code that controls the left side of the
>>page.  This code utilizes the functions in the util.php include.  As it
>>stands now the include fails because the util.php file cannot be found.  I
>>really don't want to modify this include statement for each of my pages
>>depending on their depth relative to the directory containing the include
>>files.
>>
>>Granted I could flatten the site structure and get rid of this problem but
>>that would create considerable complexity when trying to work on the site.
>>
>>I was thinking about creating an environment PATH to the inc directory as
>>one way to keep the include code that same and still be able to access the
>>util.php file.
>>
>>Any suggestions??
>>
>>Thanks,
>>Rudy
>>
>>_______________________________________________
>>talk mailing list
>>talk at lists.nyphp.org
>>http://lists.nyphp.org/mailman/listinfo/talk
>>    
>>
>
>Michael G. Southwell =================================
>DNEBA Enterprises
>81 South Road
>Bloomingdale, NJ 07403-1419
>973/492-7873 (voice and fax)
>southwell at dneba.com
>http://www.dneba.com
>======================================================
>
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03
>
>_______________________________________________
>talk mailing list
>talk at lists.nyphp.org
>http://lists.nyphp.org/mailman/listinfo/talk
>  
>




More information about the talk mailing list