English 中文(简体)
• 如何将扼杀物改为PHP的象征
原标题:How to convert string to symbol in PHP
  • 时间:2012-05-17 21:10:11
  •  标签:
  • php

如何将体现为具体文号的密码转换成*>/code>或其他内容。

I m currently working on change password page. I would like to display the password to page, and i want to avoid the password overlook by someone, so i want to covert the password s string to symbol like * with same lengths. An example like <input type="password" />.

5. 我的坏官......

最佳回答
$output_password = str_repeat ( * , strlen ($input_password));
问题回答

如果你寻找一种简单的方式,仅仅制造一系列星号,等于密码长度:

$modified = str_repeat( "*", strlen( "secretpass" ) );

echo $modified; // **********

您在超文本中不出你的密码,你就形成了你的密码。 这很容易由斯特鲁-雷塔功能完成:

<?php
$password = "MyPasswordThatIWantToMask";
$maskedPassword = str_repeat("*", strlen($password));
?>

Now you just output the $maskedPassword as the value of the password field.

然而,另一个非常有趣的事情:你们如何知道用户的密码长度? 我真诚地希望你能够发表你的口号,而不是把它们放在简单案文上。

这样做:

$passwordstring = "password";
$outputpassword = "";
while(strlen($outputpassword)<strlen($passwordstring))
{
    $outputpassword .= "*";
}

echo $outputpassword

一种办法是使用密码的输入,但将其提供给残疾人。

<input打字=残疾密码=残疾数值=某些密码/>

虽然这里有许多答案表明,str_repeat(),但我怀疑这是你想要的。 毕竟,任何辅助工具都可以产生一种特征,如果能够像你正确指出的那样简单地使用<条码>和斜线;投入类型=“密码”/>(即,你仍然能够从源代码上获得密码,但为什么两人都把一个混淆的领域集中起来? 或者,不仅如此,它有固定的固定数目* ?

我怀疑你正在寻找这样的东西:

<?php

  $thePassword = "thisIsMyPassword";

?>

<input type="text" id="input_user_types_in" value="<?php echo str_repeat( * , strlen($thePassword)); ?>" />
<input type="hidden" id="value_to_post_back" name="value_to_post_back" value="<?php echo $thePassword; ?>" />

<script type="text/javascript">

  var textInput = document.getElementById( input_user_types_in );
  var hiddenInput = document.getElementById( value_to_post_back );

  textInput.onfocus = function() {
    this.value = hiddenInput.value;
  };

  textInput.onblur = function() {
    var i;
    hiddenInput.value = this.value;
    this.value =   ;
    for (i = 0; i < hiddenInput.value.length; i++) {
      this.value = this.value +  * ;
    }
  };

</script>

a fiddle around with it ;-





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...