0

I've been debugging a PHP script on my local server using NetBeans and XDebug. Even with xdebug.show_local_vars = 1 set in php.ini Netbeans will only occasionally display local arrays in a function.

For example, in a minimal script like this:

<?php
test();
function test() {
  $dow = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
  $tod = ['AM', 'PM', 'EVE'];
  $mat = ['', '', '', '', '', '', ''];
}

I can view $mat in Netbean's variables window but not the other two. Changing the array names makes no difference.

Any thoughts on why $mat shows up but not the others?

6
  • Are you saying this exact script works as you suggest, because when I run it in NetBeans 10.0 I can see all 3 arrays and there contents in the Variables window Commented Jul 16, 2019 at 9:55
  • Although I have xdebug.show_local_vars=9 but cannot remember why Commented Jul 16, 2019 at 9:57
  • @RiggsFolly: Xdebug regards any non-zero value here as true. Yes, it works just as I describe on my local server. I'm actually running Netbeans 8.2 (on Win10). Perhaps this is the difference between us? Commented Jul 16, 2019 at 10:48
  • Could be OPCache (quite likely; remember: it is disabled for CLI by default .. so debugging the same via CLI or web may show diff results (in terms of "showing up variable in a list")). P.S. In your code sample, those arrays are not used anywhere in a function, so may have been "optimized". You can alwasy tell Xdebug to log all communications with debug client and see what data it sends to (or receives from) NetBeans. Commented Jul 16, 2019 at 11:12
  • @LazyOne: Good point about optimisation. I should have mentioned that I originally met the problem in a working function where the array variables are used but got the same result. Commented Jul 16, 2019 at 11:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.