snrecords Posted February 1, 2009 Share Posted February 1, 2009 Hi all, I can't figure why my function is not displaying properly!!! I call to a function within a class that's supposed to display a variable. It displays fine when I call to function on the front end, but when I call it from another function within the same class, it displays before the hyperlink its supposed to be in!! Here's the function calling to the allposts function. function renderPrev($tag='<<', $addition) { if($this->page > 1) { return '<a href="'.$this->php_self.$this->allposts($addition).'&number='.($this->page-1).'">'.$tag.'</a>'; } else {return $tag;} } Now here's the allpost function: function allposts($posts=array()) { foreach ( $posts as $key => $value ) { // Mask field names with more appropriate User friendly names if ($value != ""){ echo "&".$key."=".trim($value); } } } and here is how it oddly displays before the hyperlink that it's supposed to be in ... &keyword=a First << 1 2 3 >> Last The "&keyword=a" is supposed to show in the hyperlink! not as plain text before the hyperlinks! Please help!! Link to comment https://forums.phpfreaks.com/topic/143361-losing-my-mind-text-appears-before-hyperlink/ Share on other sites More sharing options...
Snart Posted February 1, 2009 Share Posted February 1, 2009 It's because you are using echo in the second function. It will echo the line to the screen instead of inserting it in the href that you are concatenating in the first function. Your second function needs to "return $whatever" instead of "echo $whatever". Link to comment https://forums.phpfreaks.com/topic/143361-losing-my-mind-text-appears-before-hyperlink/#findComment-751897 Share on other sites More sharing options...
snrecords Posted February 1, 2009 Author Share Posted February 1, 2009 Snart ... you're Smart... you're brilliant ... thank you ssooo much. Link to comment https://forums.phpfreaks.com/topic/143361-losing-my-mind-text-appears-before-hyperlink/#findComment-751900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.