Ph0enix Posted June 25, 2006 Share Posted June 25, 2006 Hi, im still learning PHP and iv just started to learn about the $_GET thing.To test it i used this:[code]<?phpprint $_GET["test"];?>[/code]So then if i typed in my address bar[a href=\"http://localhost/stuff/page.php?test=hello\" target=\"_blank\"]http://localhost/stuff/page.php?test=hello[/a]Then i would get a page that displays "hello".But i want to know how do i call a function.So if i used this code for example.[code]function square_number($number) { $square= $number * $number; return $square;}[/code]How would i call this function, so on the page it would show the result of this function.Thanks. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 25, 2006 Share Posted June 25, 2006 Did you read the fine manual on [a href=\"http://www.php.net/manual/en/functions.returning-values.php\" target=\"_blank\"]using the return[/a] statement in functions? The first example tells you how to do that.Ken Quote Link to comment Share on other sites More sharing options...
Ph0enix Posted June 25, 2006 Author Share Posted June 25, 2006 Ok thanks.But erm isnt there somthing i could write in the address bar to veiw the result of the function like..[a href=\"http://localhost/stuff/page.php?test=function(sqare_number)\" target=\"_blank\"]http://localhost/stuff/page.php?test=function(sqare_number)[/a](i know this is wrong)Cause on Postnuke you have to do something like this to display a function Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 25, 2006 Share Posted June 25, 2006 You could do something using a url like:www.whatever.com/number=2&function=squareThen your php would be:[code]<?php$func = $_GET['function'];echo call_user_func($func, $_GET['number']);function square_number($number) { $square= $number * $number; return $square;}?>[/code] Quote Link to comment 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.