double dollar

Costas

Administrator
Staff member
reference :
http://php.net/manual/en/language.variables.variable.php

snap129.png

<br>
Fig.1 - At start, we have a plain form with POST method and an element named <b style="color:red">newpass</b>.
<br>
JavaScript:
//test.php
<?php
    $blockKeys = array('_SERVER','_SESSION','_GET','_POST','_COOKIE','charset','ip','islinux','url','url_info','doc_root','fm_self','path_info');
	
    foreach ($_POST as $key => $val) //LOOP through POST variables
    	if (array_search($key,$blockKeys) === false)
    		{
    			echo "{$key} - {$val}.<br/>";

    			$$key=$val;
    		}
    	
    	
    echo $newpass;

	echo "<form method='post']";
	echo "<input type='text' name='newpass' placeholder='type a password' required></input><br/><br/>";
	echo "<button type='submit']Set Password</button><br/>";
	echo "</form>";
<br>
snap1291.png



Fig.2 - When submitted using the $$ (line 10) creates a variable <b style="color:red">newpass</b> (aka $key) and set the value submitted (aka $val).
 
Top