从java脚本调用函数时PHP中的错误[重复]

时间:2022-07-24 16:04:44

This question already has an answer here:

这个问题在这里已有答案:

$func=$_GET['func']?$_GET['func']:$_POST['func'];

While calling this function following error is showing

正在显示跟随错误调用此函数

Notice: Undefined index: func in C:\wamp\www\Web Engg final project\phplogin.php on line 2

this error us showing ?

这个错误我们显示?

1 个解决方案

#1


0  

It seems, you are not getting $_GET['func'] also $_POST['func'].

看来,你还没有获得$ _GET ['func'] $ _POST ['func']。

You are assuming that if $_GET['func'] is not set, there will be $_POST['func'].

你假设如果没有设置$ _GET ['func'],就会有$ _POST ['func']。

Instead of it, add a logic:

而不是它,添加一个逻辑:

1) Create a new variable $func, default it to blank.

1)创建一个新的变量$ func,将其默认为空白。

2) If isset($_GET['func']), assign to it.

2)如果是isset($ _ GET ['func']),则分配给它。

3) If isset($_POST['func']), assign to it.

3)如果是isset($ _ POST ['func']),则分配给它。

Code:

$func = '';
if (isset($_GET['func'])) {
 $func = $_GET['func'];
}
else if (isset($_POST['func'])) {
 $func = $_POST['func'];
}

#1


0  

It seems, you are not getting $_GET['func'] also $_POST['func'].

看来,你还没有获得$ _GET ['func'] $ _POST ['func']。

You are assuming that if $_GET['func'] is not set, there will be $_POST['func'].

你假设如果没有设置$ _GET ['func'],就会有$ _POST ['func']。

Instead of it, add a logic:

而不是它,添加一个逻辑:

1) Create a new variable $func, default it to blank.

1)创建一个新的变量$ func,将其默认为空白。

2) If isset($_GET['func']), assign to it.

2)如果是isset($ _ GET ['func']),则分配给它。

3) If isset($_POST['func']), assign to it.

3)如果是isset($ _ POST ['func']),则分配给它。

Code:

$func = '';
if (isset($_GET['func'])) {
 $func = $_GET['func'];
}
else if (isset($_POST['func'])) {
 $func = $_POST['func'];
}