Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用vscode运行PHP_Php_Html_Visual Studio Code_Http Status Code 405 - Fatal编程技术网

如何使用vscode运行PHP

如何使用vscode运行PHP,php,html,visual-studio-code,http-status-code-405,Php,Html,Visual Studio Code,Http Status Code 405,我试图创建一个简单的HTML表单,将用户重定向到服务器显示的感谢消息,并用PHP编写。然而,我所做的一切似乎都不管用。每次尝试运行代码时,我都会得到一个405。如果我刷新页面,它将开始下载。我正在使用live server扩展,并且已经安装了PHP HTML文件: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="vie

我试图创建一个简单的HTML表单,将用户重定向到服务器显示的感谢消息,并用PHP编写。然而,我所做的一切似乎都不管用。每次尝试运行代码时,我都会得到一个405。如果我刷新页面,它将开始下载。我正在使用live server扩展,并且已经安装了PHP

HTML文件:

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel = "stylesheet" type = "text/css" href = "styles-signup.css">
    <script type = "text/javascript" src = "script-signup.js"></script>

</head>
<body>
    <div>
        <h1 class = "title"></h1>
    </div>
    <div class = "form">
        <h1 id = "header">Create Your Account</h1>
        <form method = "POST" id = "signup" action = "action.php">
            <input name = "firstName" type = "text" placeholder="First Name" required id = "fname">
            <input name = "lastName" type = "text" placeholder = "Last Name" required id = "lname">
            <input name = "Email" type = "email" placeholder="email, e.g. person@gmail.com" required id = "mail">
            <input name = "newPassword" type = "password" id = "password" placeholder="Password" required minlength="8" maxlength="25">
            <input name = "passwordConfirm" type = "password" placeholder = "Confirm Password" required minlength="8" maxlength="25" id = "cpassword">
           <br>

           <input name = "gender" type = "radio" id = "male" required>
           <label for = "gender" id = "mlabel">Male</label>

           <input name = "gender" type = "radio" id = "female" required>
           <label for = "gender" id = "flabel">Female</label>

           <input name = "gender" type = "radio" id = "other" required>
           <label for = "gender" id = "olabel">Other</label>
           <br>

           <br>
           <input name = "birthdate" type = "number" min = "1920" max = "2019" placeholder="Year Of Birth" id = bd required>
           <br>

            <input name = "terms" type ="checkbox" id = "box" required>

            <p id = "tc">I agree to the <a href = "termsandconditions.txt" id = "tcLink">Terms and Conditions</a></p>

            <input name = "submit" type = "Submit" id = "button" value = "Sign up">

            <a href = "login.html" id = "login">Already have an account? Log in</a>

        </form>
    </div>

</body>
</html>

文件
创建您的帐户

男性 女性 其他


我同意

PHP文件:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <?php
    echo "<p>Hi</p>";
    ?>

</body>
</html>

文件
我得到这个错误:


您需要设置一个能够使用PHP的服务器。如果您使用windows,则可以尝试下载以下选项之一:

  • XAMPP
  • 黄蜂
  • 如果您在Linux上,则需要构建LAMP服务器。如果你在mac电脑上,我想它叫OS-X。这听起来像是你的新发明。我强烈建议您设置一个服务器,它将真正帮助您了解网站的工作原理,并使您能够编写和学习服务器端语言,如PHP和ASP


    请注意,服务器中断PHP,而不是编辑器和IDE

    欢迎光临。没有任何代码就无法帮助您。您必须缩小问题的范围,然后提供一个.VSCode只是一个编辑器。它无法执行PHP代码。你需要PHP可执行文件来执行它。你目前使用的是什么平台,Windows还是Linux?当我在Windows上下载xampp时,我是否需要对Vs代码进行任何额外的配置以使其工作?Vs代码只是一个编辑器,它不解析或解释代码,因此不需要对Vs代码做任何额外的操作。您必须在XAMPP根目录中构建项目才能使其正常工作。