phphtmlvisual-studio-codexampp

vs code not recognizing php code inside html


As you can see that my php code is showing error and is not been recognized by the vs code.My separate .php file is running smoothly but i cannot write php code inside html.I am using xampp, linux, vs code.

The code:

myphp.html

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

<form method="POST" action="myphp.php">

    Name : <input type="text" name="name">

    <span class="error">* <?php echo $nameEmp; ?></span>

    <br>

    E-mail : <input type="text" name="email">

    <br>

    Link : <input type="text" name="link">

    <br>

    Comment : <textarea name="comment" rows="5" cols="40"></textarea>

    Gender :

    <input type=" radio" name="gender" value="female">Female

    <input type="radio" name="gender" value="male">male

    <br>

    <input type="submit" name="submit" value="Submit">

</form>

</body

</html>

editor: editor screenshot


Solution

  • You have written the correct syntax for php but for php to work you have to change the file extension to .php rather than .html