Code
Result

PHP code example: imagesavealpha

Set the flag to save full alpha channel information (as opposed to single-color transparency) when saving PNG images. See documentation.

You can try this function yourself. Just edit the code and on "Run" to see the result.