Php tags no recognize in html

Question:
in this piece of code in theory everything is correct, isn’t it?
the file name is index.html
in vscode everything has the colors for an html file but the <?php ?> tags which are in white and the php code inside doesn’t work.
anybody can explain this, please

Repl link:

code snippet
<!DOCTYPE html >
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <div class="container">
        <div class="left"> 111111111111111
            <?php echo "hello there";  ?>
        </div>
        <div class="center">2222222222</div>
        <div class="right">3333333333</div>
    </div>
</body>
</html>

:wave: Welcome back @footroot72!

You can’t use PHP in an HTML file. You need to rename the file to index.php.

3 Likes

In addition, ensure that you are using a PHP Repl.

Actually, the OP isn’t using Replit.

1 Like

very odd… i did that before ask here and didn’t work
just change the extension again and worked…
:ghost: :ghost: :alien: :alien:

so, the estructure of a php file can be
etc etc

or

<?php code code ?>

or all the PHP code has to be IN the html code?
lets say

php file

html code-----php code ----- html code

hope this make sense… :grimacing: :thinking:

what does this mean? :worried: :thinking: :thinking:

“OP” stands for “original poster”.

1 Like

perhaps mark this one (the one that i replied to) as solution instead?

1 Like

But renaming the file was the solution.

The post you replied to doesn’t make that clear, so my post should be marked instead

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.