denoteone Posted April 8, 2009 Share Posted April 8, 2009 can you call a function with different parameters from that same function? example: function hello_test($text){ if ($text == "hello"){ echo $text; }else{ hello_test('hello'); } hello_test('goodbye'); Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/ Share on other sites More sharing options...
Maq Posted April 8, 2009 Share Posted April 8, 2009 can you call a function with different parameters from that same function? What gives you doubt, have you tried? Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/#findComment-804876 Share on other sites More sharing options...
denoteone Posted April 8, 2009 Author Share Posted April 8, 2009 I am getting nothing to the screen with this page. <?PHP ini_set ("display_errors", "1"); error_reporting(E_ALL); function hello_test($text){ if ($text = 'hello'){ echo $text; }else{ hello_test('hello'); } hello_test('goodbye'); echo "not working"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/#findComment-804879 Share on other sites More sharing options...
Maq Posted April 8, 2009 Share Posted April 8, 2009 You never closed your function... With proper indentation this could have been easily detected. Try this: ini_set("display_errors", "1"); error_reporting(E_ALL); function hello_test($text){ if ($text == 'hello'){ echo $text; } else { hello_test('hello'); } } hello_test('goodbye'); ?> EDIT: You know this will always echo "hello", right? Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/#findComment-804882 Share on other sites More sharing options...
denoteone Posted April 8, 2009 Author Share Posted April 8, 2009 thanks I will pay more attention to the indentation. yes I know. I am jsut try to test something. I hav an issue with my other script that calls a funtion with in a function. I am not getting any errors but I am not seeing the result I want. if (strpos($fp,"Redirected")){ if(strpos($fp,"whois.ripe.net")){ $whois_ip_servernew = 'whois.ripe.net'; whois_ip($whois_ip_servernew, '-1', 'FALSE', $visitor_ip); }else{ return $fp; } }else{ return $fp; } Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/#findComment-804892 Share on other sites More sharing options...
Maq Posted April 8, 2009 Share Posted April 8, 2009 Same problem as before... Try: if (strpos($fp,"Redirected")){ if(strpos($fp,"whois.ripe.net")){ $whois_ip_servernew = 'whois.ripe.net'; whois_ip($whois_ip_servernew, '-1', 'FALSE', $visitor_ip); } else { return $fp; } } else { return $fp; } Quote Link to comment https://forums.phpfreaks.com/topic/153219-call-a-function-from-with-in-a-function/#findComment-804905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.