Directly in PHP, all you need is to output the 410 header:
header( "HTTP/1.1 410 Gone" );
For safety, it is recommended to call
Suppose you have a handful of pages, you can either just make one file for each or modify the .htaccess using a
RewriteRule that maps all gone pages to one PHP file which sends the 410 status as shown above.
Technically, you do not need the PHP at all since the .htaccess can send the status based rules which you set such as:
RewriteRule ^contact/ - [L,R=410]
RewriteRule ^about/ - [L,R=410]
For a large number of such pages, I usually encode the logic in a custom error page written in PHP. It is called for when a file is not found and it can perform a lookup to determine if it should return the 410 header or not (and do other things as needed, including collecting statistics on how often these pages get accessed).