Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Now that you've coded your solution to the practice problem, I'll show you how I did it. Remember, there are almost always more than one way to solve a problem.
Feedback, please!
We're looking for feedback on this new type of practice workshop. When you're finished, could you please review the workshop by filling out this short form? We appreciate it!
How did it go,
were you able to complete the challenge?
0:00
If no, no worries you can watch my
solution compared to what you wrote and
0:03
then try the challenge again.
0:08
In step one we were asked to create
a variable named programmer and
0:11
set it's value equal to Ada Lovelace,
we start with the dollar sign.
0:15
Programmer equals and
then within quotes, Ada Lovelace.
0:19
Step two we were to create
another variable named year, and
0:25
set its value equal to 1843.
0:29
Dollar sign year equals 1843.
0:34
Because this is an integer and
we're going to use it as a string.
0:38
It doesn't really matter if
we use quotes or not quotes.
0:43
Either one would work.
0:47
PHP will change your variables
to best match the situation.
0:50
Step 3, replace programmer in the message
string with the variable programmer.
0:55
And replace year in the message
string with the variable year.
1:00
Because our message string
was within single quotes,
1:05
if we added the programmer variable,
directly within the string,
1:09
it would just give us $programmer.
1:14
Instead, before programmer,
I close the string, and
1:18
use the string concatenation character,
period.
1:22
I then put programmer,
followed again by another period.
1:27
And this time, I changed the last
part of our message to double quotes.
1:32
When a variable is used within
a string that has double quotes,
1:38
the value of that variable is used.
1:43
Step four is to display
the message string to the screen.
1:46
In this case, we used echo message.
1:50
If your solution was different than mine,
that's great.
1:54
Seldom is there only one solution.
1:57
If you see something
interesting in my code,
2:00
you should try implementing
it in your own program.
2:02
Keep practicing so
you can master these new skills.
2:06
Until next time, happy coding.
2:09
You need to sign up for Treehouse in order to download course files.
Sign up