| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #2 (permalink) |
| Senior Member Join Date: Jun 2007 Location: NamePros.com
Posts: 1,400
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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);
}
?> |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Member Join Date: Mar 2008
Posts: 46
![]() | Thanks a lot. But my problem is more complicated: <?php class a ????: NamePros.com http://www.namepros.com/programming/439274-php-how-to-pass-function-parameter.html { 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) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 |
| |
| | THREAD STARTER #5 (permalink) |
| NamePros Member Join Date: Mar 2008
Posts: 46
![]() | 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 03:26 PM.
|
| |