Lee*_*dka 7 javascript php type-conversion
在将字符串转换为整数之前一切正常.转换后,该值变为0.为什么?
<script type="text/javascript">
var offset = new Date().getTimezoneOffset(); //get client timezone differance with UTC
offset *= -1; // change sign
offset *= 60; // convert into second
console.log(offset);
</script>
<?php
echo "<br/><br/>";
$a = "<script>document.write(offset)</script>"; //getting value in string
echo $a; // this works and print : 19800
echo "<br/>";
settype($a, "integer");
echo $a; // print 0
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
59 次 |
| 最近记录: |