note 124703 added to function.readline

From: Date: Mon, 10 Feb 2020 13:41:11 +0000
Subject: note 124703 added to function.readline
Groups: php.notes 
Request: Send a blank email to php-notes+get-214076@lists.php.net to get a copy of this message
Christian's code works well, but if you want to be able to hide the user input and not echo it to screen, you need to add -s to the read command. The code below is an expanded function that allows an optional prompt and optional hiding of the input: function read_password($prompt=null, $hide=false) { if($prompt) print $prompt; $s = ($hide) ? '-s' : ''; $f=popen("read $s; echo \$REPLY","r"); $input=fgets($f,100); pclose($f); if($hide) print "\n"; return $input; } ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.195 (proxied: 83.218.130.90) ---- Manual Page -- http://php.net/manual/en/function.readline.php Edit -- https://master.php.net/note/edit/124703 Del: integrated -- https://master.php.net/note/delete/124703/integrated Del: useless -- https://master.php.net/note/delete/124703/useless Del: bad code -- https://master.php.net/note/delete/124703/bad+code Del: spam -- https://master.php.net/note/delete/124703/spam Del: non-english -- https://master.php.net/note/delete/124703/non-english Del: in docs -- https://master.php.net/note/delete/124703/in+docs Del: other reasons-- https://master.php.net/note/delete/124703 Reject -- https://master.php.net/note/reject/124703 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214076) next »