小编max*_*xgu的帖子

Git diff 工作不正确 - 许多更改

           f1---f2                 - short term branch "feature1"
          /       \
      h--h--h---h--h1--h2-         - long term branch "hofix"
     /       \   \      \
    /         \   \      \
   m----m------m---m------m--      - long term branch "master"
                   |      |
                 1e1e1e 2f2f2f
Run Code Online (Sandbox Code Playgroud)

我合并了有 2 个提交差异的分支(总共更改了 15 个文件)。并跑:

$ git show --pretty="format:" --name-only 1e1e1e..2f2f2f
Run Code Online (Sandbox Code Playgroud)

我收到了超过 42,000 个从我的项目中更改的文件。为什么?

预期:我将显示 f1、f2、h1、h2 提交的差异

PS 可能是因为“合并分支'origin/0411-hotfix'”提交?

git git-diff

2
推荐指数
1
解决办法
1403
查看次数

将stdClass转换为数组 - 键不可访问

当我做这样的事情时,我正在运行PHP7.0.9:

$s = json_decode('{"1": "xxx"}');//decode json to stdClass
$a = (array)$s;//cast to array
die(var_dump($a, $a['1'], $a[1], count($a)));
Run Code Online (Sandbox Code Playgroud)

我得到这个结果:

array (size=1)
  '1' => string 'xxx' (length=3) //<-- key 1 exists
null // $a['1'] yields null
null // $a[1] doesn't work either
int 1 // count shows there is 1 element in the array
Run Code Online (Sandbox Code Playgroud)

我期待这个结果:

array (size=1)
  '1' => string 'xxx' (length=3)
string 'xxx' (length=3) // $a['1'] should work
null
int 1
Run Code Online (Sandbox Code Playgroud)

我的问题:为什么我不能访问$a['1'],即使两个count和一个var_dump数组告诉我这个密钥存在?这是PHP中的错误,还是某种功能?

php json stdclass php-7

1
推荐指数
1
解决办法
647
查看次数

标签 统计

git ×1

git-diff ×1

json ×1

php ×1

php-7 ×1

stdclass ×1