To decode a base64 encoded image string and save it as a JPG file in PHP, you can use the following code: