Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm working in Dreamweaver, following a course from Lynda.com

The teacher has me add an echo command and then observe the code in my browser.

I simply could not understand what the purpose of this command is?

Sorry, I'm new to code. Please explain slowly. I used to work in design view.

share|improve this question

closed as off topic by Su', Christofian Oct 4 '12 at 21:13

Questions on Webmasters Stack Exchange are expected to relate to webmastering within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Welcome to Stack Exchange! This specific site is a good place to ask questions about entire websites, but for programming questions, Stack Overflow might be a better place. –  Christofian Oct 4 '12 at 21:15

2 Answers 2

up vote 1 down vote accepted

To answer your comment on the other answer:

Writing Hello Warren is static. It would be the same for everyone who visited the site. echo "Hello ".$user."!" will replace $user with whatever name you specified as your name when you created an account.

As an example, when you create an account on facebook and fill out your profile, your name, birthdate, etc. are all saved in a database. When you put something like $user in your code, your code references the database to find out what your name is so it can display your name instad of a static element like Warren for everyone.

share|improve this answer
    
That's excellent advice, thank you. So essentially, by adding the echo command, it becomes an editable field, is that correct? My assumption then is that this is a way to create fields that would land in an allocated database? (Because the course is largely about databases...) –  Warren van Rooyen Oct 4 '12 at 18:56
    
It doesn't create an editable field, it prints out a line of code. So this is what is happening: We have a database that stores information in tables. Lets say we have a table called the users table, and in the users table we will have a bunch of columns, like first_name, last_name, email_address. in the HTML of your website, you want to be able to reference that information saved in the database, so you have to write a line of code to do that. In this case the line of code could be read out as "say "Hello 'user_name_of_person_logged_in'" or "Hello Warren" –  Arel Oct 4 '12 at 19:02
    
Yikes, I may still be a bit lost then. What I understood you were saying is that it will create an editable field in the site where to your example, after ".%user."!", you'd have space to enter in John@hotmail.com if we're using the Facebook login analogy. Can you explain then what you mean by printing a line of code? I am terribly sorry, I do feel very stupid. I'm at the start of this course and have always used design view for simple sites where I'm now trying to advance into interactive sites. –  Warren van Rooyen Oct 4 '12 at 19:06
    
No problem Warren, it's complicated stuff at first, but it gets way easier once you get the fundamentals. There are just a lot of fundamentals. Let me know if my expanded comment above helps at all –  Arel Oct 4 '12 at 19:08
    
So on the facebook example, when you create your account, you are writing to the database(adding something new to it), when you are using the echo command you are reading from the database. –  Arel Oct 4 '12 at 19:12

In php language, the point is the concatenate string symbol, and the echo function, outputs the content.

p.eg: I asumme the value of the variable $user is Warren echo "Hello ".$user."!" outputs Hello Warren!

That's it! :)

share|improve this answer
    
Thank you for your answer. I'd just like to understand you correctly there. Concatenate is the '$' symbol? If the echo outputs the content, why can't you just write the content in as regular text e.g. <title>Hello Warren</title>. Also, are you saying that the 'Hello' would then precede the 'Warren'? I'm seriously new to code view coming from working in design view, this is the first time I've needed to interact with the code instructions in Dreamweaver so please excuse my stupidity. –  Warren van Rooyen Oct 4 '12 at 18:39
    
Don't worry @WarrenvanRooyen :D The concatenate symbol is . (point) the $ is part of the var name. Variables need to be preceeded of dollar symbol. You can write the content as a regular text, but is not PHP. –  benetj Oct 4 '12 at 18:47
    
Thank you Ben. Someone else explained that this also essentially creates an input field that can send information to a database. Would I be correct then that purpose of an echo is to open a field someone can type their info into? Also, how do I press enter to make a line in this forum, it just uploads my comment each time... Thank you! –  Warren van Rooyen Oct 4 '12 at 19:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.