Re: [PHP] Setting or Getting Relative Path for PHP Includes

2004-12-21 Thread Richard Lynch
Anthony Baker wrote:

 I often use PHP includes in my files to pull in assets, but I hard code
 the relative path to the root html directory for the sites that I'm
 working on in each file. Example below:

While I happen to think using include_path and $_SERVER is a better
solution to setting up your environment, what you describe as what you
want more closely fits php.ini's auto_prepend_file and nobody has
suggested that yet.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Setting or Getting Relative Path for PHP Includes

2004-12-21 Thread Curt Zirzow
* Thus wrote Anthony Baker:
 Hey Folks,
 
 Hoping someone can aid me with a newbie-ish question.
 
 I often use PHP includes in my files to pull in assets, but I hard code 
 the relative path to the root html directory for the sites that I'm 
 working on in each file. Example below:
 
 ?php 
  $path = '/home/virtual/sitename.com/var/www/html/';  
  //relative path to the root directory
  $inc_path = $path . 'code/inc/'; 
  //path and folder the code includes folder is located
  $copy_path = $path . 'copy/';
  //path and folder the copy is located
 ?
 
 
 I'd like to be able to set the relative path as a global variable from 
 an external file so that I can modify one line of code to change the 
 relative path across the site. This will allow me for easier coding in 
 staging and development environments.

This is a good use of the define() function, what I would generally
do is create a config.php of some sort with:

?php
  define('_BASE_INCLUDE_', '/home/path/');

  define('_INCLUDE_INC_', _BASE_INCLUDE_ . 'code/inc/');
  define('_INCLUDE_CPY_', _BASE_INCLUDE_ . 'code/copy/');
?

And each file that needs this config:

?php
  require_once('config.php'); // having config.php in your
  // php_include_path
?



Curt
-- 
Quoth the Raven, Nevermore.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Setting or Getting Relative Path for PHP Includes

2004-12-20 Thread Anthony Baker
Hey Folks,
Hoping someone can aid me with a newbie-ish question.
I often use PHP includes in my files to pull in assets, but I hard code 
the relative path to the root html directory for the sites that I'm 
working on in each file. Example below:

?php
 $path = '/home/virtual/sitename.com/var/www/html/';
 //relative path to the root directory
 $inc_path = $path . 'code/inc/';   
 //path and folder the code includes folder is located
 $copy_path = $path . 'copy/';  
 //path and folder the copy is located
?
I'd like to be able to set the relative path as a global variable from 
an external file so that I can modify one line of code to change the 
relative path across the site. This will allow me for easier coding in 
staging and development environments.

What's the best way to do so? Can anyone provide a code example?
Either that, or is there a way to call this variable from the server 
itself so that it's automatically -- and correctly -- set?

Thanks,
Anthony
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Setting or Getting Relative Path for PHP Includes

2004-12-20 Thread Jason Wong
On Tuesday 21 December 2004 04:41, Anthony Baker wrote:

 Either that, or is there a way to call this variable from the server
 itself so that it's automatically -- and correctly -- set?

Use a combination of one or more items from $_SERVER.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I think if you say you're going to do something and don't do it, that's
trustworthiness.

George W. Bush
August 30, 2000
From an CNN online chat.
*/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Setting or Getting Relative Path for PHP Includes

2004-12-20 Thread phpninja
I usually use a global variables file included in every page and map
my directories that way.. example, have the file you include on each
page have these line of code in it:

?php

$GLOBALS['images'] = /images/;
$GLOBALS['inc''] = /incl/;
?

then those directories are mapped, all you have to do is use it this
way, I chose images and and include directory for an example

to use it for an image
img src=?= $GLOBALS['images'] ?whatever.jpg

To do includes for a stylesheet or somethin:
link href=?= $GLOBALS['inc'] ?style.css type=text/css rel=stylesheet:

-phpninja

-Original Message-
From: Anthony Baker [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 20, 2004 12:41 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Setting or Getting Relative Path for PHP Includes

Hey Folks,

Hoping someone can aid me with a newbie-ish question.

I often use PHP includes in my files to pull in assets, but I hard code 
the relative path to the root html directory for the sites that I'm 
working on in each file. Example below:

?php   
  $path = '/home/virtual/sitename.com/var/www/html/';   
  //relative path to the root directory
  $inc_path = $path . 'code/inc/';  
  //path and folder the code includes folder is located
  $copy_path = $path . 'copy/'; 
  //path and folder the copy is located
?


I'd like to be able to set the relative path as a global variable from 
an external file so that I can modify one line of code to change the 
relative path across the site. This will allow me for easier coding in 
staging and development environments.

What's the best way to do so? Can anyone provide a code example?

Either that, or is there a way to call this variable from the server 
itself so that it's automatically -- and correctly -- set?


Thanks,

Anthony

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Setting or Getting Relative Path for PHP Includes

2004-12-20 Thread Jordi Canals
Can use a directive on your .htaccess:

php_value  include_path   /your/include/path/here

This can also be set on your httd.conf  in a virtual server basis. If
you have access to php.ini is better to set the include there.

Regards,
Jordi.

On Mon, 20 Dec 2004 12:41:06 -0800, Anthony Baker
[EMAIL PROTECTED] wrote:
 Hey Folks,
 
 Hoping someone can aid me with a newbie-ish question.
 
 I often use PHP includes in my files to pull in assets, but I hard code
 the relative path to the root html directory for the sites that I'm
 working on in each file. Example below:
 
 ?php
   $path = '/home/virtual/sitename.com/var/www/html/';
   //relative path to the root directory
   $inc_path = $path . 'code/inc/';
   //path and folder the code includes folder is located
   $copy_path = $path . 'copy/';
   //path and folder the copy is located
 ?
 
 I'd like to be able to set the relative path as a global variable from
 an external file so that I can modify one line of code to change the
 relative path across the site. This will allow me for easier coding in
 staging and development environments.
 
 What's the best way to do so? Can anyone provide a code example?
 
 Either that, or is there a way to call this variable from the server
 itself so that it's automatically -- and correctly -- set?
 
 Thanks,
 
 Anthony
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php