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 git.master, git.master_jit, rfc.property-hooks
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.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.31 ms | 401 KiB | 8 Q