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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.