181

このエラーが発生していますが、頭も尻尾もできません。

正確なエラー メッセージは次のとおりです。

致命的なエラー: 48 行目の /home/curricle/public_html/descarga/index.php の書き込みコンテキストで関数の戻り値を使用できません

48 行目は次のとおりです。

if (isset($_POST('sms_code') == TRUE ) {

ここで何が起こっているのでしょうか?

完全な機能は次のとおりです。

function validate_sms_code() {

    $state = NOTHING_SUBMITED;

    if (isset($_POST('sms_code') == TRUE ) {
        $sms_code = clean_up($_POST('sms_code'));
        $return_code = get_sepomo_code($sms_code);

        switch($return_code) {

          case 1:
            //no error
            $state = CORRECT_CODE;
            break;

          case 2:
            // code already used
            $state = CODE_ALREADY_USED;
            break;

          case 3:
            // wrong code
            $state = WRONG_CODE;
            break;

          case 4:
            // generic error
            $state = UNKNOWN_SEPOMO_CODE;
            break;

          default:
            // unknown error
            $state = UNKNOWN_SEPOMO_CODE;
            throw new Exception('Unknown sepomo code: ' . $return_code);
            break;
        }

    } else {
        $state = NOTHING_SUBMITED;
    }
    dispatch_on_state($state);
}
4

12 に答える 12

113

もしかして

if (isset($_POST['sms_code']) == TRUE ) {

ちなみに、あなたは本当に意味があります

if (isset($_POST['sms_code'])) {
于 2009-10-07T16:23:43.273 に答える
22
if (isset($_POST('sms_code') == TRUE ) {

この行を

if (isset($_POST['sms_code']) == TRUE ) {

括弧 () を使用して$_POSTいますが、角括弧 [] が必要でした

:)

また

if (isset($_POST['sms_code']) && $_POST['sms_code']) { 
//this lets in this block only if $_POST['sms_code'] has some value 
于 2009-10-07T16:24:25.733 に答える
13

ワードプレスの場合:

それ以外の:

if (empty(get_option('smth')))

次のようにする必要があります。

if (!get_option('smth'))
于 2015-03-26T09:59:32.550 に答える
11

正しい構文 (最後に括弧がありません):

if (isset($_POST['sms_code']) == TRUE ) {
                            ^

ps == TRUE BOOLEAN (true/false) が既に返されているため、一部は必要ありません。

于 2009-10-07T16:25:29.680 に答える
5

これは、複数のシナリオで発生する可能性があります。よく知られているシナリオのリストを以下に示します。

// calling empty on a function 
empty(myFunction($myVariable)); // the return value of myFunction should be saved into a variable
// then you can use empty on your variable

// 括弧を使用して配列の要素にアクセスし、括弧を使用して関数を呼び出します

if (isset($_POST('sms_code') == TRUE ) { ...
// that should be if(isset($_POST['sms_code']) == TRUE)

これは、以下のような関数の結果をインクリメントしようとしたときにもトリガーされる可能性があります。

$myCounter = '356';

$myCounter = intVal($myCounter)++; // we try to increment the result of the intVal...
// like the first case, the ++ needs to be called on a variable, a variable should hold the the return of the function then we can call ++ operator on it.
于 2014-05-05T17:28:36.287 に答える
3

問題は()あなたが行かなければならないことです[]

if (isset($_POST('sms_code') == TRUE)

if (isset($_POST['sms_code'] == TRUE)
于 2015-05-24T12:01:41.237 に答える
1

構文エラーが原因でこのエラーがトリガーされる別のシナリオ:

ucwords($variable) = $string;
于 2017-06-23T04:13:40.873 に答える
0

私も構文エラーのためにこの問題に遭遇しました。配列インデックスで "[" の代わりに "(" を使用する:

   foreach($arr_parameters as $arr_key=>$arr_value) {
        $arr_named_parameters(":$arr_key") = $arr_value;
    }
于 2016-07-30T08:23:13.877 に答える