MarcusZ Posted June 8, 2010 Share Posted June 8, 2010 I need some help with this one. Works fine when it's not a function but now something has happened. send($reply); function send($text) { global $text; $url = "http://www.example.com"; $text = nl2br($text); $text = str_replace("<br />","%0A",$text); $text = rawurlencode($text); $replyres = file_get_contents($url . "&text=" . $text); } Quote Link to comment https://forums.phpfreaks.com/topic/204192-function-not-executing/ Share on other sites More sharing options...
premiso Posted June 8, 2010 Share Posted June 8, 2010 You need to either echo $replyres or return it and assign it. $replyres = send($reply); function send($text) { // this is not needed global $text; $url = "http://www.example.com"; $text = nl2br($text); $text = str_replace("<br />","%0A",$text); $text = rawurlencode($text); return file_get_contents($url . "&text=" . $text); } Should be somewhat of what you are looking to do. Quote Link to comment https://forums.phpfreaks.com/topic/204192-function-not-executing/#findComment-1069478 Share on other sites More sharing options...
teynon Posted June 8, 2010 Share Posted June 8, 2010 You need to declare the function before you call it. function send($text) { global $text; $url = "http://www.example.com"; $text = nl2br($text); $text = str_replace("<br />","%0A",$text); $text = rawurlencode($text); $replyres = file_get_contents($url . "&text=" . $text); } send($reply); Quote Link to comment https://forums.phpfreaks.com/topic/204192-function-not-executing/#findComment-1069479 Share on other sites More sharing options...
GoneNowBye Posted June 8, 2010 Share Posted June 8, 2010 tenyon CODE TAGS yes btw, its the global var at the top Quote Link to comment https://forums.phpfreaks.com/topic/204192-function-not-executing/#findComment-1069482 Share on other sites More sharing options...
premiso Posted June 8, 2010 Share Posted June 8, 2010 You need to declare the function before you call it. Are you sure on that? In fact, PHP parses through code first, means it loads functions no matter where they are in the code with the exception that they are not in an include file. You can place function calls anywhere you want to, as long as that function is in the current context of the code somewhere (again with the exception of being in an include). Quote Link to comment https://forums.phpfreaks.com/topic/204192-function-not-executing/#findComment-1069489 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.