Jump to content

I'm such a noob, but I have a question about my code


kathmeejee

Recommended Posts

I hope no one rolls their eyes at me, lol, but I literally, just made my first PHP script, but I ran into a snag.

 

Okay so the code I did was

 

<!DOCTYPE html>
<html>
<body>

<?php

echo <h1>"my First PHP script"</h1>;

?>

</body>
</html>

 

but in firefox the outcome is always "my first PHP script?> I had added the h1 tags because it wouldn't print at all before I did. I'm trying to figure out what I did wrong.

phew, It is an actual question.  I was thinking it was a "sticky" post made by admins, and was expecting to see a long wall of text nagging users about how bad it is to ask about code, and essentially saying "oh you are a newb, tough luck, go away and do your own research before you even ask".

 

Well, I am glad this was not it.

 

 

Very glad.

 

Yeah, echo command immediately expects to see something quoted, or a variable placed after it.  It gets confused if it sees something other than a variable, or a quote mark.  HTML or any text for that matter is treated as "text" by PHP, and must be in quotes.

phew, It is an actual question.  I was thinking it was a "sticky" post made by admins, and was expecting to see a long wall of text nagging users about how bad it is to ask about code, and essentially saying "oh you are a newb, tough luck, go away and do your own research before you even ask".

 

Well, I am glad this was not it.

 

 

Very glad.

 

Yeah, echo command immediately expects to see something quoted, or a variable placed after it.  It gets confused if it sees something other than a variable, or a quote mark.  HTML or any text for that matter is treated as "text" by PHP, and must be in quotes.

Many members here are glad to help with any coding questions, being new or even experienced matters none.

Sometimes the only way to get an answer is to ask the question.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.