Reply to Problems trying to call functions in one file from another

Your name:

Reply:


Posted by Stephen Kay on 11/18/42 11:43

I'm having great difficulty grasping something which I think is probably
simple.

Is it possible to call a function in a php file, from another function that
is in a php file, in a completely different directory?

(But wait, it's not that simple. ;-)


In other words, say I have a function:


file path: root/level2/level2.php

function dosomethinglevel2()
{
//do it
}

Now, let's say this file has a bunch of code in it and a bunch of functions
and includes multiple other files in it. In fact, there's a whole batch of
..php files in /level2/ that all call each other and include each other.


Then, let's say I have another php file inside the upper level folder,
root/level1.php, and a function in it:

function callexternalfunction()
{
dosomethinglevel2(); // call function in another directory
}

However, I can't call the function because it gives an error that it's
undefined. And then, if I include the file that the function is defined in:

include("./level2/level2.php");

I get a bunch of other errors because all of the files that that file
includes are not in the correct paths anymore.

Is there some other way to include external functions, something like
prototypes in C/C++?

The only way I've been able to get this to work is to use curl in the upper
level file to call the function in the level2 folder and pass it the
parameters that I want ("GET"), but this seems horribly kludgey.

I'm not sure if that's clear, but maybe somebody knows what I'm talking
about - thanks!


--
Stephen Kay
Karma-Lab sk@karma-lab.NOSPAM.com
^^^^^^^

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация