Re: Using a variable for include statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2007-09-11 at 14:00 -0300, Jeff Benetti wrote:
> Sorry if this is a noob question, I have used PERL, TCL and VB but I am just
> getting into PHP.  If there is a better place to ask noobie questions then
> let me know.
> 
> I want to use the include statement but I want to pass the name of the file
> rather than hard code it.  It seems that PHP needs the file to be in its
> defined PATH in order to do this (or am I wrong?).
> 
> My code works OK if I use hard coding
> 
> Example (works)
> 
> include ('somefile.php')
> 
> Example (doesn't work)
> 
> $TheFile = "somefile.php"
> 
> include ($TheFile)
> 
> Am I trying to do  something that is impossible?
> 
> If it is a path problem then how do I get around this, I can control my
> local server config but I only have a local server for development.

If the first works, then the second will work unless you've trimmed out
some useful information for us to see... or maybe it's the lack of a
semi-colon after the assignment (but that's probably just a quick typo
mistake).

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux