I am just trying a simple test of php on my computer:
- Archlinux + httpd + php
- phpinfo() test is ok
- code is written with vim , no copy and paste
here is the code (taken from a book) that doesn’t work as expected:
<html>
<head><title>Test PHP </title></head>
<body>
<h1>Texte mis en avant</h1>
<?php
echo "<p>ceci est du code PHP</p>";
echo "<p>simple non?</p>";
?>
</body>
</html>
and here is what I get in browsers:
Texte mis en avant
ceci est du code PHP
“; echo “
simple non?
“; ?>
What is wromg with this? (first time I block on something such simple)
By default PHP script files have to be named with use of
.phpsuffix, to be passed to PHP interpreter as the file name suffix is what is being taken into consideration during page serving. If you use.htmlas you said, then it simply goes as is, because HTML knows nothing about PHP. So you should either rename your file to end with.php(simplest approach) or tell your http server that.htmlfiles shall also be handled by PHP. I.e. if you are using Apache and.htaccesscan be used per vhost, create.htaccessfile in root of your service with content:which will tell your httpd, that files matching given pattern shall also be considered PHP scripts.