3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * SoapClient with protection on fatal error * * @category Smile * @package Smile_Soap * @author Laurent MINGUET <lamin@smile.fr> * @copyright 2014 Smile * */ class Smile_Soap_Client extends SoapClient { /** * construct * * @param string $wsdl wsdl url to use * @param array $options table of options * * @return $this * * @link http://www.php.net/manual/en/soapclient.soapclient.php */ public function __construct($wsdl = null, $options = array()) { $options = $this->_initOptions($options); self::startErrorHandlerForFatal('WSDL'); $res = @parent::__construct($wsdl, $options); self::stopErrorHandlerForFatal(); return $res; } /** * init the options * * @param array $options array of options * * @return array */ protected function _initOptions($options) { $defaultOptions = array( 'soap_version' => SOAP_1_1, 'authentication' => SOAP_AUTHENTICATION_BASIC, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'exceptions' => true, 'timeout' => (int)ini_get('default_socket_timeout'), // in seconds ); $options = array_merge($defaultOptions, $options); ini_set('default_socket_timeout', (int)$options['timeout']); return $options; } /****************************************************************** *********** METHODES AND PROPERTIES FOR ERROR HANDLING *********** ******************************************************************/ /** * default code to use for error handling * @var null|string */ static private $_defaultCode = null; /** * start handling the error to catch fatal errors * * @param string $defaultCode default code to use * * @return void */ static public function startErrorHandlerForFatal($defaultCode) { self::$_defaultCode = $defaultCode; set_error_handler('Smile_Soap_Client::errorHandlerForFatal', E_ALL); } /** * stop handling the error to catch fatal errors * * @return void */ static public function stopErrorHandlerForFatal() { self::$_defaultCode = null; restore_error_handler(); } /** * handling the error to catch fatal errors * * @param int $errno error number * @param string|exception $errstr error message * @param string $errfile file of the error * @param int $errline line of the error * * @return void * @throws SoapFault */ static public function errorHandlerForFatal($errno, $errstr, $errfile = null, $errline = null) { $code = self::$_defaultCode; self::stopErrorHandlerForFatal(); if ($errstr instanceof Exception) { if ($errstr->getCode()) { $code = $errstr->getCode(); } $errstr = $errstr->getMessage(); } elseif (!is_string($errstr)) { $errstr = 'Unknown error'; } throw new SoapFault($code, $errstr.' (error ['.$errno.'])'); } } try { $client = new Smile_Soap_Client(); echo '---===[OK]===---'."\n"; } catch (Exception $e) { echo '---===[ERROR]===---'."\n"; print_r($e); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Class "SoapClient" not found in /in/KeX9d:11 Stack trace: #0 {main} thrown in /in/KeX9d on line 11
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'SoapClient' not found in /in/KeX9d:11 Stack trace: #0 {main} thrown in /in/KeX9d on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Fatal error: Class 'SoapClient' not found in /in/KeX9d on line 11
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Class 'SoapClient' not found in /in/KeX9d on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.29
---===[ERROR]===--- SoapFault Object ( [message:protected] => SoapClient::SoapClient(): 'uri' option is required in nonWSDL mode [string:Exception:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:Exception:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => SoapClient [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => 1 [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [previous:Exception:private] => [faultstring] => SoapClient::SoapClient(): 'uri' option is required in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.2.12 - 5.2.17
Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 ---===[ERROR]===--- SoapFault Object ( [message:protected] => SoapClient::SoapClient(): 'uri' option is required in nonWSDL mode [string:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => SoapClient [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => 1 [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [faultstring] => SoapClient::SoapClient(): 'uri' option is required in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.2.0 - 5.2.11
Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 ---===[ERROR]===--- SoapFault Object ( [message:protected] => SoapClient::SoapClient(): 'uri' option is requred in nonWSDL mode [string:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => SoapClient [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => 1 [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [faultstring] => SoapClient::SoapClient(): 'uri' option is requred in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.1.3 - 5.1.6
Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 ---===[ERROR]===--- SoapFault Object ( [message:protected] => SoapClient::__construct(): 'uri' option is requred in nonWSDL mode [string:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => __construct [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => 1 [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [faultstring] => SoapClient::__construct(): 'uri' option is requred in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.1.0 - 5.1.2
Notice: Use of undefined constant SOAP_SINGLE_ELEMENT_ARRAYS - assumed 'SOAP_SINGLE_ELEMENT_ARRAYS' in /in/KeX9d on line 46 Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 ---===[ERROR]===--- SoapFault Object ( [message:protected] => [string:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => __construct [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => SOAP_SINGLE_ELEMENT_ARRAYS [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [faultstring] => SoapClient::__construct(): 'uri' option is requred in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.0.5
Notice: Use of undefined constant SOAP_SINGLE_ELEMENT_ARRAYS - assumed 'SOAP_SINGLE_ELEMENT_ARRAYS' in /in/KeX9d on line 46 Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 Warning: set_error_handler() expects the argument (Smile_Soap_Client::errorHandlerForFatal) to be a valid callback in /in/KeX9d on line 78 ---===[ERROR]===--- SoapFault Object ( [message:protected] => [string:private] => [code:protected] => 0 [file:protected] => /in/KeX9d [line:protected] => 28 [trace:private] => Array ( [0] => Array ( [file] => /in/KeX9d [line] => 28 [function] => __construct [class] => SoapClient [type] => -> [args] => Array ( [0] => [1] => Array ( [soap_version] => 1 [authentication] => 0 [features] => SOAP_SINGLE_ELEMENT_ARRAYS [exceptions] => 1 [timeout] => 60 ) ) ) [1] => Array ( [file] => /in/KeX9d [line] => 123 [function] => __construct [class] => Smile_Soap_Client [type] => -> [args] => Array ( ) ) ) [faultstring] => SoapClient::__construct(): 'uri' option is requred in nonWSDL mode [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
Process exited with code 255.
Output for 5.0.4
Notice: Use of undefined constant SOAP_SINGLE_ELEMENT_ARRAYS - assumed 'SOAP_SINGLE_ELEMENT_ARRAYS' in /in/KeX9d on line 46 Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 Warning: set_error_handler() expects the argument (Smile_Soap_Client::errorHandlerForFatal) to be a valid callback in /in/KeX9d on line 78
Process exited with code 139.
Output for 5.0.2 - 5.0.3
Notice: Use of undefined constant SOAP_AUTHENTICATION_BASIC - assumed 'SOAP_AUTHENTICATION_BASIC' in /in/KeX9d on line 45 Notice: Use of undefined constant SOAP_SINGLE_ELEMENT_ARRAYS - assumed 'SOAP_SINGLE_ELEMENT_ARRAYS' in /in/KeX9d on line 46 Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 Warning: set_error_handler() expects the argument (Smile_Soap_Client::errorHandlerForFatal) to be a valid callback in /in/KeX9d on line 78 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>SoapClient::__construct(): 'location' option is requred in nonWSDL mode.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant SOAP_AUTHENTICATION_BASIC - assumed 'SOAP_AUTHENTICATION_BASIC' in /in/KeX9d on line 45 Notice: Use of undefined constant SOAP_SINGLE_ELEMENT_ARRAYS - assumed 'SOAP_SINGLE_ELEMENT_ARRAYS' in /in/KeX9d on line 46 Warning: ini_set() has been disabled for security reasons in /in/KeX9d on line 52 Warning: set_error_handler() expects the argument (Smile_Soap_Client::errorHandlerForFatal) to be a valid callback in /in/KeX9d on line 78 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>SoapClient::SoapClient(): 'location' option is requred in nonWSDL mode.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/KeX9d on line 23
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/KeX9d on line 23
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/KeX9d on line 23
Process exited with code 255.

preferences:
279.89 ms | 401 KiB | 461 Q