kathmeejee Posted July 30, 2014 Share Posted July 30, 2014 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><?phpecho <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. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2014 Share Posted July 30, 2014 Is your file type ".php" or ".html"? The <h1> tags need to be inside the quotes echo "<h1>my First PHP script</h1>"; or outside the php/echo <h1> <?php echo "my First PHP script"; ?> </h1> Quote Link to comment Share on other sites More sharing options...
dennis-fedco Posted July 30, 2014 Share Posted July 30, 2014 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. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted July 31, 2014 Share Posted July 31, 2014 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.