3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php # Инициализация переменных : $aResult = array(); # результирующий массив # Загрузка страницы : $sResponse = $this->curl( 'user/eggs/activate/content/form.action', array( 'code' => $sCode ) ); # Преобразование ответа в массив : $aResponse = json_decode( $sResponse, true ); # Загрузка страницы : $sResponse = $this->curl( 'user/eggs/activate/content/form.action', array( 'code' => $sCode, 'token' => $aResponse['data']['token'] ) ); # Если зачисления не произошло : if( mb_substr_count( $sResponse, $sCode ) != 2 ) { if( count( $aExplode = explode( '<p>', $sResponse ) ) < 3 ) throw new Exception( 'undefined error' ); $aExplode = explode( '</', $aExplode[2] ); throw new Exception( trim( strip_tags( $aExplode[0] ) ) ); } # Парсинг суммы : if( count( $aExplode = explode( 'на сумму', $sResponse ) ) < 2 ) throw new Exception( 'error parse amount' ); $aExplode = explode( 'руб', $aExplode[1] ); $aResult['dAmount'] = preg_replace( '/[^0-9\.]+/', '', str_replace( ',', '.', trim( $aExplode[0] ) ) ) - 0; # Парсинг примечания : if( count( $aExplode = explode( 'Комментарий к переводу', $sResponse ) ) < 2 ) throw new Exception( 'error parse comment' ); $aExplode = explode( '</p>', $aExplode[1] ); $aResult['sComment'] = trim( strip_tags( $aExplode[0] ) ); # Подтверждение : $aResponse = json_decode( $this->curl( 'user/eggs/activate/content/activate.action', array( 'code' => $sCode ) ), true ); # Проверка подтверждения : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || !isset( $aResponse['code']['_name'] ) || $aResponse['code']['value'] != '0' || $aResponse['code']['_name'] != 'NORMAL' ) throw new Exception( 'bad server answer: '.var_export( $aResponse, true ) ); return $aResult; $this->curl( 'settings/options/security.action' ); # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/person/change/security.action', array( 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ), true ); # Проверка ответа : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 7 || !isset( $aResponse['data'] ) || !isset( $aResponse['data']['token'] ) ) throw new Exception( json_encode( $aResponse ) ); # Инициализация переменных : $sToken = $aResponse['data']['token']; # Загрузка страницы : $aResponse = json_decode( $this->curl( 'user/person/change/security.action', array( 'token' => $sToken, 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ), true ); # Проверка ответа : if( isset( $aResponse['code'] ) && isset( $aResponse['code']['value'] ) && $aResponse['code']['value'] == 0 ) return true; # Проверка ответа : if( !isset( $aResponse['code'] ) || !isset( $aResponse['code']['value'] ) || $aResponse['code']['value'] != 4 || !isset( $aResponse['identifier'] ) || $aResponse['identifier'] <= 0 ) throw new Exception( json_encode( $aResponse ) ); # Инициализация переменных : $iIdentifier = $aResponse['identifier']; # Загрузка страницы : $this->curl( 'user/confirmation/form.action', array( 'identifier' => $iIdentifier, 'token' => $sToken, 'type' => 'SMS_CONFIRMATION', 'value' => $bOff ? 'false' : 'true' ) ); return $iIdentifier;
based on rSfNr
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/qEFlE:7 Stack trace: #0 {main} thrown in /in/qEFlE on line 7
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Using $this when not in object context in /in/qEFlE on line 7
Process exited with code 255.