You cannot specify the schema name in this command. You can change the search path for just one query by using the following code:
<?php
pg_query($conn, "SET search_path TO myschema;");
$copy_to = pg_copy_to($conn, 'tablename');
pg_query("RESET search_path;");
?>