PHP 301 Redirect Permanently is used for redirecting user from one page to other page or other websites. This is useful for that page which you want to remove from your website and put new pages or replacing old domain with new domain. With the 301 permanent redirect search engines indexes new url or domain and removed old from their indexing.
To redirect users to other domain put following code in php script.
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.other-website.com"); ?>
To redirect users from old.php to new.php on same domain. Edit old.php and put following code at top of file
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: http://mydomain.com/new.php"); ?>