How to redirect page with PHP and code 301 or 302

Sometime somebody need to redirect page with PHP. You can use following snippet:

<?php 
header("Location: http://anydomain.tld/new/location/", true, 301); 
?>

Please note the numbers 301 and 302.
301 is permanent redirect, 302 is temporary.