How to use PHP scripts?


#1

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?


#2

What type of file are you saving it as?


#3

Oh, the forum website processed all html sorry!

I’m saving it as index.html


#4

Try saving as index.php?


#6

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:


#7

Thank you, it helped! :slight_smile:


#8