Invoke www.error in PHP

Is there a way I can set www.error manually from the PHP script that I call?

Probably you’ll need to do that with the headers returned.
Read about the ‘header’ function in your favorite PHP manual.