Is it permissible to claim copyright on a PHP script based on code from a book?

It is not permissible to claim copyright on a PHP script based on code from a book, as the code is considered derivative work and the original author holds the copyright. To use code from a book in your script, you should either obtain permission from the author or use the code as a reference to write your own original code.

// Example PHP script using code from a book as a reference
// Original code from book: $result = someFunction($input);
// Your own original code:
$input = "example input";
$result = yourFunction($input);

function yourFunction($input) {
  // Your implementation here
  return $input;
}