[Help] Script to get contents of a function from other file.

[Help] Script to get contents of a function from other file.

am 14.11.2007 09:37:08 von Kesavan Muthuvel

I need a function such that it returns a string holding the contents
of function in other php file..,

************************************************************ *******************************************
allFunctions.php:
********************
class clsA{

function a{
..,
..if($test){ //testing condition.,
}
..,aNewFn(); // Calling other function..,
...
..
while(){..,
..,
}
..,
}

function b{
..,
..if($test){ //testing condition.,
}
..,aNewFn2(); // Calling other function..,
...
..
while(){..,
..,
}
..,
}

}//End of Class.,


************************************************************ *******************************************
getFnContent.php //Now I need a function such as .,
**********************

$tmpFnContent = getFunctionContents("allFunctions.php","clsA","a") ;
echo "Function 'a' in Class 'clsA' has".$tmpFnContent ;

function getFunctionContents($file,$class,$functionName) /*I want
to develop this function*/
{
----
----
return $functionContent ;
}

?>


Hope U understand the problem.,

Please explain me how to achieve this by providing me a algorithm or
flow..,
Is there any library function ., to meet my requirement?

Thanks..,

Kesavan Muthuvel
m.kesavan@hotmail.com

Re: Script to get contents of a function from other file.

am 14.11.2007 18:28:13 von colin.mckinnon

On 14 Nov, 08:37, Kesavan wrote:
> I need a function such that it returns a string holding the contents
> of function in other php file..,
>
> ************************************************************ *******************************************
> allFunctions.php:
> ********************
> class clsA{
>
> function a{
> ..,
> ..if($test){ //testing condition.,
> }
> ..,aNewFn(); // Calling other function..,
> ...
> ..
> while(){..,
> ..,
> }
> ..,
> }
>
> function b{
> ..,
> ..if($test){ //testing condition.,
> }
> ..,aNewFn2(); // Calling other function..,
> ...
> ..
> while(){..,
> ..,
> }
> ..,
> }
>
> }//End of Class.,
>
> ************************************************************ *******************************************
> getFnContent.php //Now I need a function such as .,
> **********************
> >
> $tmpFnContent = getFunctionContents("allFunctions.php","clsA","a") ;
> echo "Function 'a' in Class 'clsA' has".$tmpFnContent ;
>
> function getFunctionContents($file,$class,$functionName) /*I want
> to develop this function*/
> {
> ----
> ----
> return $functionContent ;
>
> }
>
> ?>
>
> Hope U understand the problem.,
>
> Please explain me how to achieve this by providing me a algorithm or
> flow..,
> Is there any library function ., to meet my requirement?
>
> Thanks..,
>
> Kesavan Muthuvel
> m.kesa...@hotmail.com

If you want to examine the file without loading it into the current
namespace then try token_get_all(), alternatively include the file and
use function_exists() / method_exists() or the reflection API - see
http://www.php.net/manual/en/language.oop5.reflection.php

C.

Re: Script to get contents of a function from other file.

am 15.11.2007 07:44:53 von Kesavan Muthuvel

Thanks Colin McKinnon.. for your kind reply.,,

So., Can I implement my requirement with token_get_all()..,
Is there any samples avail on www related to my problem?

With u I implement What I want..,

Kesavan Muthuvel
m.kesavan@hotmail.com

On Nov 14, 10:28 pm, "C. (http://symcbean.blogspot.com/)"
wrote:
> On 14 Nov, 08:37, Kesavan wrote:
>
>
>
> > I need a function such that it returns a string holding the contents
> > of function in other php file..,
>
> > ************************************************************ *******************************************
> > allFunctions.php:
> > ********************
> > class clsA{
>
> > function a{
> > ..,
> > ..if($test){ //testing condition.,
> > }
> > ..,aNewFn(); // Calling other function..,
> > ...
> > ..
> > while(){..,
> > ..,
> > }
> > ..,
> > }
>
> > function b{
> > ..,
> > ..if($test){ //testing condition.,
> > }
> > ..,aNewFn2(); // Calling other function..,
> > ...
> > ..
> > while(){..,
> > ..,
> > }
> > ..,
> > }
>
> > }//End of Class.,
>
> > ************************************************************ *******************************************
> > getFnContent.php //Now I need a function such as .,
> > **********************
> > >
> > $tmpFnContent = getFunctionContents("allFunctions.php","clsA","a") ;
> > echo "Function 'a' in Class 'clsA' has".$tmpFnContent ;
>
> > function getFunctionContents($file,$class,$functionName) /*I want
> > to develop this function*/
> > {
> > ----
> > ----
> > return $functionContent ;
>
> > }
>
> > ?>
>
> > Hope U understand the problem.,
>
> > Please explain me how to achieve this by providing me a algorithm or
> > flow..,
> > Is there any library function ., to meet my requirement?
>
> > Thanks..,
>
> > Kesavan Muthuvel
> > m.kesa...@hotmail.com
>
> If you want to examine the file without loading it into the current
> namespace then try token_get_all(), alternatively include the file and
> use function_exists() / method_exists() or the reflection API - seehttp://www.php.net/manual/en/language.oop5.reflection.php
>
> C.