Can't figure out how to use pwm with an optocoupler and a MOSFET

CrossRoads:
I see IRF530 shown as both N-channel and P-channel
http://www.digikey.com/product-search/en?x=0&y=0&lang=en&site=us&KeyWords=irf530

Now that is a bizarre arrangement, bound to cause big trouble!