We use if to introduce a possible or unreal situation or condition. We use when to refer to the time of a future situation or condition that we are certain of: You can only go in if you've got your ticket.