仅当我使用var_dump或echo而不使用调试器断点时,变量才会被设置

问题描述 投票:0回答:1

所以我从我的PHP代码中得到了这种奇怪的行为。

public function index() {
  $interval = (int)('60');
  // echo $interval;
  // If I uncomment and put a breakpoint above, 
  // I can see the variable $interval value in my debugger.
  // But without an 'echo' or 'var_dump' statement, 
  // value is not getting set in $interval.
  die;
}

当我使用'echo'或'var_dump'将$ interval变量写入输出流时,$ interval变量正确显示并设置。但是如果我在间隔初始化之后使用调试器中断执行而不是写入输出流变量没有设置。

以下是调试器截图。

这有效!

This works!

这不!

This does not!

知道为什么这种奇怪的行为?如果我在一个单独的php文件中运行它没有问题。问题仅存在于Codeigniter实例中。

PHP版本:7.2.8 Codeigniter:3.1.5

php codeigniter xdebug
1个回答
0
投票

<?php
function writeMsg() {
    echo "Hello world!";
}

writeMsg(); // call the function
?>
© www.soinside.com 2019 - 2024. All rights reserved.