How to create a zip file using PHP

In this video I have shown how you can create a zip format of any file using PHP code.
This example is shown in XAMPP server installed in windows 10 pc.

You can set the output name and input name in the code. If the location of the input varies, You should set the directory correctly.

In the above code, sample.pdf is zipped into
So the output in the root directory is shown below.