简体   繁体   中英

Getting wrong variable name while echoing query string

date_default_timezone_set('Africa/Lagos');

function generateRandom($length = 24)  
{
 return bin2hex(openssl_random_pseudo_bytes($length));
 }
$value = "5000";
$now = new DateTime("now");
$rid = generateRandom();
$current_timestamp = strtotime("now");
$timestamp = "&timestamp";  
$valueToHash = "rid='$rid'&value='$value'&timestamp=".$now->getTimestamp();
echo $valueToHash; 
die;

When i am echoing $valueToHash output is -

rid='1f7cde02bd050f17e29a4c0f42e55bae96e4543a87133921'&value='5000'×tamp=1530082495

but output should be like-

rid='1f7cde02bd050f17e29a4c0f42e55bae96e4543a87133921'&value='5000'&timestamp=1530082495

Need help in this..

I guess you're outputting raw text on an html page.

The result is that, at a certain point, you're printing &timestamp , which actually contains an HTML entity ( &times ) which, guess what, gets interpreted and output as × .

If you don't need to actually display this but only use it inside, say, the href attribute of an a element, you can disregard the problem and leave it as it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM