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. Link to comment https://forums.phpfreaks.com/topic/12864-_get-stuff/ 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 Link to comment https://forums.phpfreaks.com/topic/12864-_get-stuff/#findComment-49355 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 Link to comment https://forums.phpfreaks.com/topic/12864-_get-stuff/#findComment-49358 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] Link to comment https://forums.phpfreaks.com/topic/12864-_get-stuff/#findComment-49369 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.