I’ve occasionally needed to transfer files while on the go, without having brought an extra cable along. A single cable was all I needed: it charges my phone and also allows me to connect the device to a computer whenever necessary.
On Android, a notification lets you select "Charging only." On an iPhone, you’re asked for confirmation before data transfer is permitted. In both cases, the same cable can be used for both charging and data transfer—it’s the software on the phone and the computer that determines what is allowed, not the cable itself.
If you only want to charge your device, you can disable data transfer in its settings or use a cable designed exclusively for charging. Ultimately, understanding this distinction is all it takes to choose the right cable and travel a little bit lighter.