|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to include a file in a function which is in a class.
include($DOCUMENT_ROOT . "/globals/somefilelalala.php"); This code works on all other pages except when I try to place it inside the function. I get the following error: Warning: Failed opening '/globals/somefilelalala.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/gotlag/public_html/template.php on line 8 Any ideas? Note: I'm trying to make a template which needs some files included like menu, usersonline, etc...
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 |
|
#2
|
|||
|
|||
|
War-Angel,
What version of PHP are you running? Try using $_SERVER['DOCUMENT_ROOT']. Also, can you post the code where your code is contained. Also, if that doesn't work, try this: include("http://www.gotlag.com/<path-to-the-php-file>/file.php"); ^^ Replace gotlag.com with whatever URL you're using it for.. I'm just assuming it's for your site. ![]()
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction Last edited by FrankieShakes : September 22nd, 2002 at 09:17 PM. |
|
#3
|
|||
|
|||
|
or try this...
You always will need to "import" variables from the global scope into functions. So this will not work
PHP Code:
instead do this... PHP Code:
Just remeber that modifying this value inside the function will actually modify the global value as well. Another way to do it would be PHP Code:
That would work in all PHP4 versions. |
|
#4
|
|||
|
|||
|
if you want to avoid the global, you can do this
foobar("testing"); then the function looks like function foobar($test) { echo $test; } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Include error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|