| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #2 (permalink) |
| NamePros Regular | Well if you want to call a function you can use the call_user_func function. If you need to pass the function name as parameter you would do this... Code: <?php
function myFunction($callbackFunc)
{
// Do whatever you got to here...
// and then..
call_user_func($callbackFunc);
}
?>
|
| |
| | #3 (permalink) |
| NamePros Member | Thanks a lot. But my problem is more complicated: <?php class a { public function f() { echo "af"; } } function func($g) { class b extends a { public function f() { echo "bf"; // I want to call function g from here } } $b1 = new b(); $b1->f(); } function g() { echo "g"; } // From here I want to call function func with argument the funtion g ?> |
| |
| | #4 (permalink) |
| Senior Member | why have you got a class within a function (class b is within the func function)? This looks like very bad code design.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #5 (permalink) |
| NamePros Member | I need to call the following lines of code -the body of function func- from many locations in my application. So I use a function. Is it a bad idea? (class a -not b- has a lot lines of code) Also functions like g are more than 50! class b extends a { public function f() { echo "bf"; // I want to call function g from here } } $b1 = new b(); $b1->f(); Last edited by evdoxos; 03-02-2008 at 02:26 PM. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |