Php 为什么我的var_dump()仅在函数外部使用时才显示?
在调试WordPress functions.php文件中的一些代码时,我正在学习Php 为什么我的var_dump()仅在函数外部使用时才显示?,php,wordpress,var-dump,Php,Wordpress,Var Dump,在调试WordPress functions.php文件中的一些代码时,我正在学习var\u dump() 在函数中使用var\u dump()时,它不会显示在页面上。以下内容不会显示任何内容: function my_function() { $test_variable = 'some words'; var_dump($test_variable); } 但是当var\u dump()在函数之外时,它显示良好。这将显示转储: $test_variable = 'some
var\u dump()
在函数中使用var\u dump()
时,它不会显示在页面上。以下内容不会显示任何内容:
function my_function() {
$test_variable = 'some words';
var_dump($test_variable);
}
但是当var\u dump()
在函数之外时,它显示良好。这将显示转储:
$test_variable = 'some words';
var_dump($test_variable);
为什么my
var\u dump()
仅在函数外部使用时显示?您没有在任何地方调用函数
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();
这显示了这两个语句。你调用函数了吗?函数调用在哪里?刚刚弄明白了!我现在觉得有点傻。