0

我的 WAMP 有问题(我认为),我无法从应用程序中的任何函数中获取任何内容,例如 var_dump($_POST) 可以正常工作,直到我将其放入函数中然后什么也没有出现,与简单的回显相同,单独工作正常但函数中没有任何内容,甚至返回值也不起作用。有什么想法吗??

<?php
var_dump($_POST); //works fine

if(isset($_POST)) {
 function dump() {
  echo 'HELLO WORLD!'; //not working even if I call this function
 }
}
4

4 回答 4

0

尝试这个...

if(isset($_POST)) {
 dump();
}

function dump() {
  echo 'HELLO WORLD!'; //not working even if I call this function
}
于 2013-09-21T08:40:25.273 回答
0

尝试这个

 <?php

    if(isset($_POST)) {
    dumpit();
    }

     function dumpit() {
      echo 'HELLO WORLD!'; //not working even if I call this function
     }

确保你在页面上发布了一些东西,否则函数 dumpit() 将不会被调用。如果您不发布某些内容,则可以像这样进行测试...

 <?php

    dumpit();

     function dumpit() {
      echo 'HELLO WORLD!'; //not working even if I call this function
     }

请为初学者阅读一些教程。

于 2013-09-21T08:41:10.370 回答
0

我在我的本地主机上执行了你的代码(我正在运行 XAMPP)并且它正常执行。我试过代码:

$a =10;
if(isset($a))
{
    function dump($str)
    {
        echo $str; //not working even if I call this function 
    }
    dump('Calling from within the if statement');
}

dump('Calling from outside the if statement');

然后,我调用了这个 dump(); 在 if() 条件范围内和 if 条件范围外都起作用。它在这两种情况下都运作良好。

我认为问题出在您的 $_POST 变量上。尝试重新考虑它。

于 2013-09-21T08:48:44.767 回答
0

我解决了,看来我的 WAMP 挂了,所以我重新启动了 Windows,WAMP 工作正常,现在可以工作了,谢谢你们的时间!很乐意随时提供帮助;-)

于 2013-09-21T08:56:58.483 回答