This is a very common question, but a very good one for new photographers!
You know when you take out your nice, big phone to take a picture, but you decide to zoom in so you put your fingers on the screen and pull them apart to zoom in? Or when you have a little digital camera and you press the zoom button and on the lens it says something like, “x8 Digital Zoom?”
Technically speaking, you are not zooming in at all. You’re cropping. Digital zoom just means that the image being displayed on your screen and “zoomed in” is having the edges cropped away and is being pre-processed inside the camera before being output as a jpeg. It’s being “digitally zoomed.” The pre-processing aspect is why it may look slightly different when you do “digitally zoom” rather than taking the full image and cropping it yourself, but not by all that much. This will either just give you a smaller-resolution image or enlarge the pixels to give you the same resolution it would have with an un-zoomed image.
Optical zoom means that the actual optics of the lens are moving in such a way that they are actually magnifying the light that falls on your sensor from what’s directly in front of the lens (barring tilt-shift lenses, but those rarely zoom). Optical zoom preserves the details of the image, rather than just enlarging the pixels or lowering the resolution.
One easy way to tell the difference on your camera or phone, if you can’t see the words “Digital Zoom” or “Optical Zoom” anywhere is just to zoom in! If you can’t see any parts moving, it’s a digital zoom. If you can see parts moving, it’s probably an optical zoom. I have to say “probably” because some built-in lenses will try to adjust focus as they crop in, so sometimes there are moving pieces in there.