I want to run a script on a PHP file, but it is not running. It runs the header before the function runs so don't know how to run first the script
iniciales();
header('Location: Lista_libros.php');//This runs before the funtion
function iniciales(){
echo '<script type="text/javascript">
alert("test");
</script>';
}