just learning got a simple question

Hey everyone I have just started learning php, I got a book for beginners for php5/mysql
I have noticed some of the example codes won’t work where i am having to research it out on how it should be to work, which btw is fine with me , it helps teach me better :wink:

My question is this, the chapter I am on is doing “if” statements, the code is to make a single HTML file for a form instead of a HTML + PHP file

After correcting how he had everything written for the “if” statement I ended up with this
[php]
echo “<input type = text”;
echo “<input name = userName\n”;
echo “<input type = submit”;
[/php]

My question is what does the “\n” stand for?
and also should I be adding the “>” at the end of those just to make it properly

Thanks in advance

just an update to my original question
looks like I didn’t need the “\n”

I changed my code some making it look like this and got some of my question answered
[php]
if (empty($userName))
{
echo “Please Enter Your Name:”;
echo “<input type = text”;
echo “”;
echo “
”;
echo “”;
echo “”;
}
[/php]
so the question I asked about “>” is answered :slight_smile:
but the “\n” is still a mystery

“\n” is telling the parser ‘start a new line here please’

Note: on windows machines it is “\r\n” and also it has to be in double quotes “\n” for it to be parsed.
If you put it in single quotes ‘\n’ the parser will skip over it and simply print ‘\n’ to the screen/output.

Hope that helps you understand what it’s for,
Red :wink:

Hey red

Thank you for that reply. Thats what I was noticing and also figured but when in a doubt ask is one of my modos

Really appreciate your response there :slight_smile:

Glad i could help :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service