public static function writeStringToFile($string, $filename, $append = false)
    {
        $errorHandler = static::getErrorHandler();
        
        $result = false;
        if ($append === true) {
            $result = file_put_contents($filename, $string, FILE_APPEND);
        } else {
            $result = file_put_contents($filename, $string);
        }
        
        if ($result === false) {
            $error = error_get_last();
            $errorMessage = null;
            if ($error != null && array_key_exists('message', $error)) {
                $errorMessage = $error['message'];
            }
            
            if (isset($errorMessage)) {
                $errorHandler->throwException(
                    'An error occurred in output file "'.$filename.'": '.$errorMessage,
                    ErrorHandlerInterface::OUTPUT_FILE_ERROR
                );
            } else { // @codeCoverageIgnore
                $errorHandler->throwException(
                    'An error occurred in output file "'.$filename.'"',
                    ErrorHandlerInterface::OUTPUT_FILE_ERROR
                );
            } // @codeCoverageIgnore
        } // @codeCoverageIgnore
            
        return $result;
    }
public static function writeStringToFile($string, $filename, $append = false)
    {
        $errorHandler = static::getErrorHandler();
        
        $result = false;
        if ($append === true) {
            $result = file_put_contents($filename, $string, FILE_APPEND);
        } else {
            $result = file_put_contents($filename, $string);
        }
        
        if ($result === false) {
            $error = error_get_last();
            $errorMessage = null;
            if ($error != null && array_key_exists('message', $error)) {
                $errorMessage = $error['message'];
            }
            
            if (isset($errorMessage)) {
                $errorHandler->throwException(
                    'An error occurred in output file "'.$filename.'": '.$errorMessage,
                    ErrorHandlerInterface::OUTPUT_FILE_ERROR
                );
            } else { // @codeCoverageIgnore
                $errorHandler->throwException(
                    'An error occurred in output file "'.$filename.'"',
                    ErrorHandlerInterface::OUTPUT_FILE_ERROR
                );
            } // @codeCoverageIgnore
        } // @codeCoverageIgnore
            
        return $result;
    }
public static function writeStringToFile ( $ string , $ filename , $ append = false ) { $ errorHandler = static :: getErrorHandler ( ) ; $ result = false ; if ( $ append === true ) { $ result = file_put_contents ( $ filename , $ string , FILE_APPEND ) ; } else { $ result = file_put_contents ( $ filename , $ string ) ; } if ( $ result === false ) { $ error = error_get_last ( ) ; $ errorMessage = null ; if ( $ error != null && array_key_exists ( 'message' , $ error ) ) { $ errorMessage = $ error [ 'message' ] ; } if ( isset ( $ errorMessage ) ) { $ errorHandler -> throwException ( 'An error occurred in output file "' . $ filename . '": ' . $ errorMessage , ErrorHandlerInterface :: OUTPUT_FILE_ERROR ) ; } else { // @codeCoverageIgnore $ errorHandler -> throwException ( 'An error occurred in output file "' . $ filename . '"' , ErrorHandlerInterface :: OUTPUT_FILE_ERROR ) ; } // @codeCoverageIgnore } // @codeCoverageIgnore return $ result ; }
Writes the specified string to the specified file.

@param string $string the string to write to the file.
@param string $filename the name of the file to write the string.
@param boolean $append if true, the file is appended if it already exists. If false,
the file is created if it doesn't exist, and overwritten if it does.

@throws PhpCapException if an error occurs.

@return mixed false on failure, and the number of bytes written on success.
Writes the specified string to the specified file .