Jump to content

Losing my Mind - text appears before hyperlink!


snrecords

Recommended Posts

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!! 

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".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.