301 Redirect using PHP

Using php you can permanently redirect one URL to another, using the below code in a php file;
<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.newsite.co.uk/”);
exit();
?>