From: Dasn on 23 Feb 2010 04:28 Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a function. For example: <?php $rf = new ReflectionFunction('strstr'); echo $rf; ?> =============== output ================== Function [ <internal:standard> function strstr ] { - Parameters [3] { Parameter #0 [ <required> $haystack ] Parameter #1 [ <required> $needle ] Parameter #2 [ <optional> $part ] } } The problem is there's no 'return type' (i.e. 'string' in this example) info about the function. Could you tell me how to retrieve the 'return type'? Thanks. -- Dasn
From: shiplu on 23 Feb 2010 07:40 2010/2/23 Dasn <dasn(a)lavabit.com>: > Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a > function. > For example: > <?php > > $rf = new ReflectionFunction('strstr'); > echo $rf; > ?> > =============== output ================== > > Function [ <internal:standard> function strstr ] { > > Â - Parameters [3] { > Â Â Parameter #0 [ <required> $haystack ] > Â Â Parameter #1 [ <required> $needle ] > Â Â Parameter #2 [ <optional> $part ] > Â } > } > > The problem is there's no 'return type' (i.e. 'string' in this example) > info about the function. > > Could you tell me how to retrieve the 'return type'? > Thanks. I think PHP doesnt support it. In ReflectionParameter class you'll see there is no parameter type too. May be this is because PHP is loosely typed language. -- Shiplu Mokaddim My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest)
From: Daniel Egeberg on 23 Feb 2010 09:17 2010/2/23 Dasn <dasn(a)lavabit.com>: > Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a > function. > For example: > <?php > > $rf = new ReflectionFunction('strstr'); > echo $rf; > ?> > =============== output ================== > > Function [ <internal:standard> function strstr ] { > > Â - Parameters [3] { > Â Â Parameter #0 [ <required> $haystack ] > Â Â Parameter #1 [ <required> $needle ] > Â Â Parameter #2 [ <optional> $part ] > Â } > } > > The problem is there's no 'return type' (i.e. 'string' in this example) > info about the function. > > Could you tell me how to retrieve the 'return type'? > Thanks. > > > -- > Dasn That's not possible. Consider this function: function foo() { switch (rand(0, 1)) { case 0: return 42; case 1: return 'bar'; } } What should the return type be? -- Daniel Egeberg
From: Bruno Fajardo on 23 Feb 2010 09:22 2010/2/23 Daniel Egeberg <degeberg(a)php.net> > > 2010/2/23 Dasn <dasn(a)lavabit.com>: > > Hello guys, I try to use 'ReflectionFunction' to retrieve the info of a > > function. > > For example: > > <?php > > > > $rf = new ReflectionFunction('strstr'); > > echo $rf; > > ?> > > =============== output ================== > > > > Function [ <internal:standard> function strstr ] { > > > > - Parameters [3] { > > Parameter #0 [ <required> $haystack ] > > Parameter #1 [ <required> $needle ] > > Parameter #2 [ <optional> $part ] > > } > > } > > > > The problem is there's no 'return type' (i.e. 'string' in this example) > > info about the function. > > > > Could you tell me how to retrieve the 'return type'? > > Thanks. > > > > > > -- > > Dasn > > That's not possible. Consider this function: > > function foo() > { > switch (rand(0, 1)) { > case 0: return 42; > case 1: return 'bar'; > } > } > > What should the return type be? Mixed? http://www.php.net/manual/en/language.pseudo-types.php#language.types.mixed > > -- > Daniel Egeberg > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php
From: tedd on 23 Feb 2010 09:31 At 3:17 PM +0100 2/23/10, Daniel Egeberg wrote: >2010/2/23 Dasn <dasn(a)lavabit.com>: > > Could you tell me how to retrieve the 'return type'? >> Thanks. >> >> >> -- >> Dasn > >That's not possible. Consider this function: > >function foo() >{ > switch (rand(0, 1)) { > case 0: return 42; > case 1: return 'bar'; > } >} > >What should the return type be? > >-- >Daniel Egeberg It can be anything you want to test for -- check out: is_int(); is_nan(); is_float(); is_long(); is_string(); IOW, is_whatever(); Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
|
Next
|
Last
Pages: 1 2 3 Prev: $_POST vs $_REQUEST Next: PLEASE, PLEASE, PLEASE - HELP ME GET OFF THIS LIST |