How to use PHP scripts?


I typed the following code:

<?php echo 'hello world '; ?>

Mamama mia

And the website does not display hello world, it only displays mamma mia.

What is wrong? Any suggestions?


What type of file are you saving it as?


Oh, the forum website processed all html sorry!

I’m saving it as index.html


Try saving as index.php?


Yes, @Infinity is correct. When a file is named .html, it’ll only process content that contains HTML. Any PHP in that file will be displayed as plain text, because the server isn’t processing the data. When the PHP code is in a .php file, the server knows that it needs to process the code and it’ll work correctly. :slight_smile:


Thank you, it helped! :slight_smile: