内容简介:参见英文答案 >我不知道如何谷歌这一个,所以我在这里问.当我宣布一个变量$something = 0759变成61时,为什么会发生这种情况.我知道答案必须非常简单,所以请原谅我的愚蠢.翻译自:https://stackoverflow.com/questions/22040815/why-does-variable-0759-give-out-61
参见英文答案 > What does a leading zero do for a php int? 4个
我不知道如何谷歌这一个,所以我在这里问.当我宣布一个变量$something = 0759变成61时,为什么会发生这种情况.我知道答案必须非常简单,所以请原谅我的愚蠢.
它是一个Integer字面值,您声明一个前导零的八进制数字.
$something = 0759; // octal
八进制数字系统是base-8数字系统.
您只能使用0-7之间的数字(其他数字将被丢弃).
$a = 0759; $b = 075; var_dump($a==$b); // bool(true)
http://www.php.net/manual/en/language.types.integer.php
你可以用ltrim跳过零.
$a = ltrim("0759", 0);
echo $a; // 759
// and reformat as suggested with str_pad or printf
echo str_pad($a, 4, "0", STR_PAD_LEFT);
翻译自:https://stackoverflow.com/questions/22040815/why-does-variable-0759-give-out-61
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 写不写注释? Elixir 给出另外一个答案
- Tor被曝多个0 day漏洞,官方给出回应!
- 算法 – 给出一个单词,打印其索引,可以相应地增加单词
- Gradle多项目给出“找不到属性”sourceSets’在项目“错误
- 有人说Julia比Python好,还给出了5个理由
- 强化学习如何提升ICU抢救效率?普林斯顿大学给出答案
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Numerical Recipes 3rd Edition
William H. Press、Saul A. Teukolsky、William T. Vetterling、Brian P. Flannery / Cambridge University Press / 2007-9-6 / GBP 64.99
Do you want easy access to the latest methods in scientific computing? This greatly expanded third edition of Numerical Recipes has it, with wider coverage than ever before, many new, expanded and upd......一起来看看 《Numerical Recipes 3rd Edition》 这本书的介绍吧!