PHP Tutorial for Beginners 5 String concatenation [w/ subs]



00:00:00 – I just wanted to point out that in the
00:00:02 – last video we only cover the two main
00:00:04 – type of variables and of course that was
00:00:06 – string and number variables but there
00:00:08 – are other variables and we will cover
00:00:09 – them later in the course that being said
00:00:11 – you can see here I've added three new
00:00:13 – string variables one with the string
00:00:15 – hello how are you doing our second
00:00:17 – string variable will contain the name
00:00:19 – mark and then our third string variable
00:00:21 – will contain today and it will also
00:00:24 – point to our second string variable so
00:00:26 – you'll notice that for a string variable
00:00:28 – free we're actually referencing string
00:00:30 – variable to to get its value which of
00:00:32 – course is mark so what we're going to do
00:00:34 – is we're going to combine the first
00:00:36 – string variable with the third string
00:00:38 – variable and that should produce the
00:00:39 – sentence hello how are you doing today
00:00:41 – mark and then of course it's a question
00:00:43 – mark now you'll see the intellisense
00:00:45 – here from notepad plus plus PHP
00:00:47 – recognizes that we are in fact
00:00:49 – referencing this variable you can see
00:00:50 – that the color of this text is bulb so I
00:00:53 – know that I have to use the value of
00:00:54 – string variable to for the output here
00:00:57 – so again the point of this lesson is to
00:00:59 – use concatenation now concatenation do
00:01:01 – simply means chaining something together
00:01:03 – or combining something together so
00:01:05 – that's what we're gonna do so we want to
00:01:07 – use our favorite function echo and then
00:01:09 – let's go ahead and specify our string
00:01:11 – variable one and here is what you use to
00:01:14 – concatenate strings together you use a
00:01:17 – period it's that simple so this so that
00:01:20 – will be used to combine our string
00:01:22 – variable and then let's specify string
00:01:24 – variable three and there we go and of
00:01:27 – course we need to close this out with a
00:01:29 – semicolon so let's go ahead and save
00:01:32 – this and let's go ahead over here and
00:01:34 – select our lesson dot PHP and there you
00:01:37 – can see we got exactly what you wanted
00:01:39 – and you'll notice here that we also
00:01:41 – received the value from string variable
00:01:43 – to it was in fact rendered correctly so
00:01:47 – we get the sentence hello how are you
00:01:48 – doing today mark now you can also use
00:01:51 – single quotes for your string variable
00:01:53 – instead of double quotes so let's do
00:01:55 – that on this third string variable now I
00:01:57 – want you to notice something you notice
00:02:00 – this isn't bold anymore did you notice
00:02:01 – the intelligence changed here that's
00:02:03 – because there is a subtle difference
00:02:05 – between using double quotes and single
00:02:08 – quotes and that is when you use single
00:02:10 – quotes PHP treats this as
00:02:12 – text absolute text so this no longer is
00:02:16 – treated as a variable it's just plain
00:02:18 – old text now so when we reload this over
00:02:20 – here we should just get dollar string
00:02:23 – there too of course that's not going to
00:02:25 – make a lot of sense but that's what we
00:02:26 – said we just want the raw text now so
00:02:29 – let's go ahead and save this and let's
00:02:30 – reload our lesson dot PHP and there you
00:02:33 – can see this is exactly what I expected
00:02:34 – to get we will only get plain text
00:02:37 – because these single quotes treat
00:02:39 – everything is just raw text so that's
00:02:42 – the subtle difference between using
00:02:43 – double quotes and single close I do
00:02:46 – think for the most part you'll probably
00:02:47 – use double quotes but I just wanted to
00:02:49 – explain the difference ok that's going
00:02:50 – to do it for this video I will see you
00:02:52 – guys in the next video
00:03:01 – you


Video Url:
http://youtu.be/Lpc208qEIsk

Comments

comments