Tag: Logic

Stripe API implementation error/exception handling

Stripe error handling

Stripe error handling

Stripe API libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. The Stripe recommends for writing code that gracefully handles all possible API exceptions.

Below Error Handling code is compatible with latest stripe API version


For old stripe versions i.e Stripe API v1.18.0 use below Error Handling code

For more details please check .


How to Copy directory/files from windows command line/prompt

COPY – It will allow you to quickly copy files from one location to another location.

Syntex > copy source_file_name destination_file_name

XCOPY – The xcopy command allows you to copy files and directories from one location to another location. This makes it much more suitable for copying folders. xcopy also has many modifiers which gives advanced users more control over the copying process.

Syntex > xcopy /E /I source_dir_name destination_die_name

Reference of /E and /I
/E – This option makes sure that empty subfolders are copied to the destination.
/I – Avoids prompting if the destination is a folder or file.

How can I offer a gzipped csv file for download using PHP?


I have a PHP script that creates  csv file from the db. I would like to have the script to create the csv data and immediately make a .gzip file available for download. Can you please give me some ideas?


You can easily apply gzip compression with the gzencode function.


How to swap two numbers without using a temporary variable in PHP ?

We have two variables (parameters) “x” & “y”, here we do swap of two variables without using a third variable (parameters).

1) Swap numbers using Arithmetic Operators –
In below example we use addition and subtraction operation to do swap of 2 numbers

In below example we use multiplication and division operation to do swap of 2 numbers


2) Swap numbers using Bitwise XOR Operators –

In multiplication, we can not able to use 0 (zero), because of it make multiplication result as zero.

Your comments are appreciated!

Till than Happy Coding 🙂