-1

I'm learning about var_dump() while trying to debug some code in my WordPress functions.php file.

When var_dump() is used inside a function it does not display on the page. Nothing will display with this:

function my_function() {
    $test_variable = 'some words';
    var_dump($test_variable);
}

But when var_dump() is outside of a function it displays fine. This displays the dump:

$test_variable = 'some words';
var_dump($test_variable);

Why is my var_dump() only showing when used outside of the function?

TinyTiger
  • 1,801
  • 7
  • 47
  • 92

1 Answers1

4

You have not called function any where.

function my_function() {
    $test_variable = 'some words from inside my_function';
    var_dump($test_variable);
}

$test_variable = 'some words from out side my_function';
var_dump($test_variable);

my_function();

This show the both statement.

crazyKida
  • 56
  • 4