<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC2%2FVariables-in-PHP%2FEnglish</id>
		<title>PHP-and-MySQL/C2/Variables-in-PHP/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC2%2FVariables-in-PHP%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Variables-in-PHP/English&amp;action=history"/>
		<updated>2026-04-07T14:56:20Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Variables-in-PHP/English&amp;diff=518&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{|Border=1 !Time !Narration |- |0:00 |Welcome to a basic tutorial on PHP variables.  |- |0:04 |Let me quickly go through a few things first.  |- |0:07 |PHP variables are very eas…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C2/Variables-in-PHP/English&amp;diff=518&amp;oldid=prev"/>
				<updated>2012-11-29T06:28:33Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{|Border=1 !Time !Narration |- |0:00 |Welcome to a basic tutorial on PHP variables.  |- |0:04 |Let me quickly go through a few things first.  |- |0:07 |PHP variables are very eas…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{|Border=1&lt;br /&gt;
!Time&lt;br /&gt;
!Narration&lt;br /&gt;
|-&lt;br /&gt;
|0:00&lt;br /&gt;
|Welcome to a basic tutorial on PHP variables. &lt;br /&gt;
|-&lt;br /&gt;
|0:04&lt;br /&gt;
|Let me quickly go through a few things first. &lt;br /&gt;
|-&lt;br /&gt;
|0:07&lt;br /&gt;
|PHP variables are very easy to use; I'm sure you'll understand them straight away. &lt;br /&gt;
|-&lt;br /&gt;
|0:14&lt;br /&gt;
|You don't need to declare them and they're very easy to write. &lt;br /&gt;
|-&lt;br /&gt;
|0:18&lt;br /&gt;
|You can add a value to a variable half way through the script. &lt;br /&gt;
|-&lt;br /&gt;
|0:23&lt;br /&gt;
|Also, they automatically convert to the data type you require.&lt;br /&gt;
|-&lt;br /&gt;
|0:28&lt;br /&gt;
|So there's no need to declare them in a different way each time, or create a value for them each time. &lt;br /&gt;
|-&lt;br /&gt;
|0:36&lt;br /&gt;
|So, for example, let's create our PHP tags here and our content goes in between. &lt;br /&gt;
|-&lt;br /&gt;
|0:41&lt;br /&gt;
|Okay. Now we start with the dollar sign and then we have our variable name. &lt;br /&gt;
|-&lt;br /&gt;
|0:47&lt;br /&gt;
|Please note that you can't start with a &amp;quot;number&amp;quot;. So I can't start with a '1'. &lt;br /&gt;
|-&lt;br /&gt;
|0:53&lt;br /&gt;
|What I can start with is an &amp;quot;underscore&amp;quot; or a &amp;quot;letter&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|0:57&lt;br /&gt;
|No other special characters are allowed except underscores, letters and numbers, as long as it doesn't start with a number. &lt;br /&gt;
|-&lt;br /&gt;
|1:05&lt;br /&gt;
|So that would be perfectly acceptable here. &lt;br /&gt;
|-&lt;br /&gt;
|1:09&lt;br /&gt;
|Okay, so I'll create a variable called &amp;quot;name&amp;quot; and that's going to be equal to a string value contained within double quotes, just like we used for the &amp;quot;echo&amp;quot; function. &lt;br /&gt;
|-&lt;br /&gt;
|1:21&lt;br /&gt;
|'My name is Alex'. &lt;br /&gt;
|-&lt;br /&gt;
|1:23&lt;br /&gt;
|On the next line, we're going to create another variable using again a dollar sign, called 'age'. That's going to be equal to '19', without double quotes. &lt;br /&gt;
|-&lt;br /&gt;
|1:33&lt;br /&gt;
|Now the reason for this is that this is an integer. &lt;br /&gt;
|-&lt;br /&gt;
|1:36&lt;br /&gt;
|You can use it for decimal values as well.  So this could be '19.5' or nineteen and a half. &lt;br /&gt;
|-&lt;br /&gt;
|1:43&lt;br /&gt;
|That would also automatically convert this into a decimal. &lt;br /&gt;
|-&lt;br /&gt;
|1:48&lt;br /&gt;
|However, at the moment it's just an integer. That's how I want it - the variable 'name' is a string and the variable 'age' is an integer. &lt;br /&gt;
|-&lt;br /&gt;
|1:57&lt;br /&gt;
|So let's try echoing these out. &lt;br /&gt;
|-&lt;br /&gt;
|2:00&lt;br /&gt;
|What we need is &amp;quot;echo&amp;quot; and the variable name, not forgetting your line terminator. &lt;br /&gt;
|-&lt;br /&gt;
|2:06&lt;br /&gt;
|Okay, let's find our file named &amp;quot;variables&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:11&lt;br /&gt;
|Okay, &amp;quot;Alex&amp;quot; has been echoed out, just like I've said here, &amp;quot;echo name&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:16&lt;br /&gt;
|Let's try and echo out my age now. &lt;br /&gt;
|-&lt;br /&gt;
|2:19&lt;br /&gt;
|It's just an integer variable and that's been echoed out here. &lt;br /&gt;
|-&lt;br /&gt;
|2:24&lt;br /&gt;
|Okay so, the thing with variables is that they're very easy to concatenate into a string. &lt;br /&gt;
|-&lt;br /&gt;
|2:30&lt;br /&gt;
|In fact, probably, concatenation is the wrong word – they're very easy to include inside your string. &lt;br /&gt;
|-&lt;br /&gt;
|2:36&lt;br /&gt;
|If you don't know what concatenation is, it just means to join two things together or to join two strings together in a line. &lt;br /&gt;
|-&lt;br /&gt;
|2:46&lt;br /&gt;
|So, an example of concatenation would be, let's see, 'concat' and then I could say, '.' and then 'ination'. &lt;br /&gt;
|-&lt;br /&gt;
|2:56&lt;br /&gt;
|Now, this would echo out 'concatination'. &lt;br /&gt;
|-&lt;br /&gt;
|2:59&lt;br /&gt;
|Let's try this. Okay? &lt;br /&gt;
|-&lt;br /&gt;
|3:03&lt;br /&gt;
|But there is a completely different tutorial on that. So, what I'll say is, for now, you don't need to include this as one of your variables when you're echoing it out. &lt;br /&gt;
|-&lt;br /&gt;
|3:14&lt;br /&gt;
|If you can't follow this, don't worry.  This is very, very simple. &lt;br /&gt;
|-&lt;br /&gt;
|3:18&lt;br /&gt;
|I'll say &amp;quot;My name is&amp;quot; name &amp;quot;and my age is&amp;quot; and put my age down. &lt;br /&gt;
|-&lt;br /&gt;
|3:24&lt;br /&gt;
|So, it's all in one string, all in one echo, and we've just got 'My name is' – plain text. &lt;br /&gt;
|-&lt;br /&gt;
|3:32&lt;br /&gt;
|Variable is called.  This is put here.  Then when age is called, the value for age is put here. &lt;br /&gt;
|-&lt;br /&gt;
|3:40&lt;br /&gt;
|So, we can refresh that and you can see that &amp;quot;My name is Alex&amp;quot;.  That's our variable. &amp;quot;and my age is 19&amp;quot; and that's our variable. &lt;br /&gt;
|-&lt;br /&gt;
|3:48&lt;br /&gt;
|So they're really easy to put into strings.   &lt;br /&gt;
|-&lt;br /&gt;
|3:52&lt;br /&gt;
|Okay, this is all you really need to know now about variables. &lt;br /&gt;
|-&lt;br /&gt;
|3:56&lt;br /&gt;
|There are other types of variables, like boolean, decimal – which I've shown you, for example like '19.5'.  &lt;br /&gt;
|-&lt;br /&gt;
|4:06&lt;br /&gt;
|You would declare them in the same way, with a dollar sign. &lt;br /&gt;
|-&lt;br /&gt;
|4:10&lt;br /&gt;
|So practice this and you can come back and learn some more advanced functionality later on, when I'm going through some other projects. &lt;br /&gt;
|-&lt;br /&gt;
|4:19&lt;br /&gt;
|Thanks for watching!  This is Joshua Mathew dubbing for the Spoken Tutorial project. (Script contributed by Bhavini Pant).&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>