我有这样的价值
function prepLogin ($id, $username, $remember, $email){
$_SESSION['id'] = $id;
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$fingerprint = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
$_SESSION['last_active'] = time();
$_SESSION['fingerprint'] = $fingerprint;
if($remember === "yes"){
rememberMe($id);
}
//call sweet alert
//echo 'REACHED PREP LOGIN'.'<br>';
echo $welcome = "<script type=\"text/javascript\">
swal({
title: \"Welcome back $username!\",
text: \"You're being logged in.\",
type: 'success',
timer: 3000,
showConfirmButton: false });
setTimeout(function(){
window.location.href = '../../index.php';
}, 3000);
</script>";
}
此值的二进制表示为
1111 1111 1111 0111 1011 1011 1111 1111
如何在PHP中将此FFF7BBFF
转换为二进制文件?我无法在网上找到这个公式?
我试过这个
FFF7BBFF
但它不起作用。它显示了这个
答案 0 :(得分:1)
base_convert是要使用的函数:http://php.net/manual/en/function.base-convert.php
$hexadecimal="FFF7BBFF";
echo base_convert($hexadecimal, 16, 2);
输出:
11111111111101111011101111111111
如果你真的想要这种格式..
$new=base_convert($hexadecimal, 16, 2);
$split = str_split($new, 4);
echo implode(' ', $split);
输出:
1111 1111 1111 0111 1011 1011 1111 1111