下载文件而不是执行

Downloads file instead of executing

运行 OSX,PHP 5.6.30。我正在尝试从 html 文件执行脚本,但它会下载文件。注意:这不能正常工作,因为 html 文件应该是 .php,但这也是在下载而不是打开它。

我试过:

https://reteps.github.io/website.html可以看到,我只在googlechrome.

测试过

HTML(应该是.php)

<!doctype html>
<html>
  <head>
    <title>

    </title>
    <link rel="stylesheet" type="text/css" href="navbar.css">
  </head>
  <body>

    <div id="menu">
        <a href="index.html">Home</a>
        <a href="https://github.com/reteps">Github</a>
        <a href="school.html">School Projects</a>
        <a href="side.html" >Side Projects</a>
        <a href="blog.html">Blog</a>
      </div>
  <form action="www/script.php" method="get">
    <input type="text" name="quizid" placeholder="kahoot id">
    <input type="submit" value="Go">
  </form>
  <p id="output">Nothing yet...</p>
  </body>
</html>

PHP

#!/usr/bin/php
<?php
$username = 'USERNAME@gmail.com';
$password = 'PASSWORD';
$loginUrl = 'https://create.kahoot.it/rest/authenticate';
$kahootId = htmlentities($_GET['quizid']);
$pageUrl = 'https://create.kahoot.it/rest/kahoots/' . $kahootId;

$loginheader = array(); 
$loginheader[] = 'content-type: application/json';
$loginpost = new stdClass();
$loginpost->username = $username;
$loginpost->password = $password;
$loginpost->grant_type = "password";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($loginpost));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 
curl_setopt($ch, CURLOPT_HTTPHEADER,$loginheader);
$store = curl_exec($ch);
curl_close($ch);
$token = json_decode($store,true)["access_token"];

//get questions
$quizheader = array(); 
$quizheader[] = 'authorization: ' . $token;
$options = array(
    'http' => array(
        'method'  => 'GET',
        'header'  => "Authorization: ".$token."\r\n"
    )   
);

$context = stream_context_create($options);
$raw_result = file_get_contents($pageUrl, false, $context);
$result = json_decode($raw_result,true)["questions"];
$myoutput = $_POST['output'];
header( "Location: website.html?output=$myoutput" );
print_r($result)
?>

来自 GitHub 页面文档:https://help.github.com/articles/what-is-github-pages/:

GitHub Pages is a static site hosting service and doesn't support server-side code such as, PHP, Ruby, or Python.