Garip PHP hatası: 'yazma bağlamında fonksiyon dönüş değeri kullanamazsınız'

4 Cevap php

Ben bu hatayı alıyorum ve ben bunun baş veya kuyruk yapamaz.

Tam bir hata iletisi:

Fatal error: Can't use function return value in write context in /home/curricle/public_html/descarga/index.php on line 48

Satır 48 olduğunu:

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

Herkes ne oluyor biliyor??

Yardımcı olur durumda PS İşte, tam fonksiyon bulunuyor:

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 Cevap

Yani

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

tesadüfen Eğer gerçekten demek olsa

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

This also happens when using empty on a function return. example:

!empty(trim($someText)) and doSomething()

because empty is not a function but a language construct (not sure), and it only takes variables examples: Yes:

empty($someVar)

No:

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

Bu satırı değiştirin

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

Köşeli parantez $ _POST için) (parentheseis kullanıyorsunuz ama istedim []

:)

VEYA

if (isset($_POST['sms_code']) && $_POST['sms_code']) { 
//this lets in this block only if $_POST['sms_code'] has some value

Sizin kodu:

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

Lütfen parantez İzle:

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

Eğer karışık [ve (ve bir kapatmayı unuttu.

Daha da iyisi:

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

isset zaten boolean verir çünkü.