На php просто:
$fragment = parse_url('https://oauth.vk.com/blank.html#code=8c888738с888bb888')['fragment'];
$code = explode('=', $fragment)[1] ?? 'none';
echo $code;
На JS еще проще:
let code = location.hash.replace('#code=','') || 'none';
console.log(code)