PHP - "print / echo" displaying closing tags - or not output

Running some PHP and embarrassed at how echo / print works.

I have this code in my index.html :

 <?php Print '<div>Hello, World!</div>'; ?> 

And the output on my page

 Hello, World!'; ?> 

If I remove the <div> tags, I get no output. using echo leads to the same behavior.

What's happening? Everything I find on Google seems straightforward.

+4
source share
1 answer

You cannot put PHP code in an HTML file (unless you tell Apache to parse the HTML files).

Rename the file to index.php

Do you have a web server with PHP configuration?

+6
source

Source: https://habr.com/ru/post/1386876/


All Articles