Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我的var_dump()仅在函数外部使用时才显示?_Php_Wordpress_Var Dump - Fatal编程技术网

Php 为什么我的var_dump()仅在函数外部使用时才显示?

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

在调试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 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();

这显示了这两个语句。

你调用函数了吗?函数调用在哪里?刚刚弄明白了!我现在觉得有点傻。