Depends what type of spell you're doing, some are combat and some are not for example a high alch would be constant exp where as a combat spell such fire blast for example would give you exp if you splash but you'd get a lot more exp if the spell hits more, if you get me?
Each magic attack spell has a base experience that you get each and every time you cast it. It's guaranteed. Any hits you get will count towards extra experience, at 4xp every 10 LP.
initial exp from spell
extra exp from damage caused by spell (in the case of spells that actually hurt like fire bolt or wind strike... not curse or stun)
but the extra exp also gives u constitution hp so if ur going for a low hp pure that messed up ur chances