Jump to content

function print outside div


MuseiKaze

Recommended Posts

Hey guys. Ive been working on a setup page which will install a few things and I've been having some problems with this function I created. It seems to print out under the <body> tag up the top even though I have it in a print statement inside a <div> tag. All of the text shows up where its ment to but the asterix's dont want to appear there.

 

This is the function, its just ment to put an asterix where the password is.

 

function asterix($pass){

$asterix = 0;

$length = strlen($pass);

while ($asterix < $length){

print '*';

$asterix++;

}

}

 

I wont type the whole print statement cause its fairly big, but its pretty much like this.

 

print '<div class="setup"><table><tr><td>Password: ' . asterix($_SESSION['password']) . '</td></tr></table></div>';

 

What am I missing that would cause it to not print in the right place? Thanks heaps

Link to comment
Share on other sites

Your using it within a print statement yet your function itself prints. make your function return your value instead.

 

It can also be written a little better.

 

function asterix($string) {
    return str_pad('', strlen($string), '*');
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.