title
PHP Front To Back [Part 3] - Variables, Constants & Data Types

description
In this video we will look at very basic PHP syntax including tags, comments, variables, constants and concatenation. CODE: Code For This Video http://www.traversymedia.com/downloads/phpsandbox/phpsandbox1.zip COURSES: Premium Eduonix Courses http://www.traversymedia.com/eduonix-courses SUPPORT THIS CHANNEL WITH A CUP OF COFFEE PER MONTH: https://www.patreon.com/traversymedia ONE TIME DONATIONS: https://www.paypal.me/traversymedia

detail
{'title': 'PHP Front To Back [Part 3] - Variables, Constants & Data Types', 'heatmap': [{'end': 132.477, 'start': 70.989, 'weight': 1}, {'end': 851.847, 'start': 830.581, 'weight': 0.777}], 'summary': "'php front to back part 3' delves into php basics, covering variables, constants, data types, and concatenation, catering to individuals with limited php knowledge and emphasizing practical examples such as creating files, exploring data types, and understanding constants.", 'chapters': [{'end': 69.985, 'segs': [{'end': 69.985, 'src': 'embed', 'start': 20.568, 'weight': 0, 'content': [{'end': 23.909, 'text': 'but I would still suggest that you watch it and just use it as a refresher.', 'start': 20.568, 'duration': 3.341}, {'end': 31.673, 'text': 'I have to do it because I want this to be for people that know nothing about PHP as well.', 'start': 25.789, 'duration': 5.884}, {'end': 34.575, 'text': "And I want them to be able to know what's going on.", 'start': 32.334, 'duration': 2.241}, {'end': 44.502, 'text': "So in this video, we're going to talk about things like just basic syntax, comments, variables, constants, and data types.", 'start': 35.135, 'duration': 9.367}, {'end': 48.685, 'text': "We'll also look at concatenation and combining variables as well.", 'start': 44.602, 'duration': 4.083}, {'end': 51.907, 'text': "Alright, so I'm using Sublime Text for my editor.", 'start': 49.165, 'duration': 2.742}, {'end': 53.548, 'text': 'If you guys want to use that, you can.', 'start': 51.967, 'duration': 1.581}, {'end': 57.912, 'text': 'If you want to use something else, Atom is another one that I use all the time.', 'start': 53.988, 'duration': 3.924}, {'end': 61.096, 'text': 'Notepad++ is alright.', 'start': 58.693, 'duration': 2.403}, {'end': 69.985, 'text': "You could even use just Windows Notepad, but I wouldn't suggest it as it doesn't have sufficient highlighting or anything like that.", 'start': 62.037, 'duration': 7.948}], 'summary': 'Introduction to php basics including syntax, variables, and data types. mentions text editors like sublime text, atom, and notepad++.', 'duration': 49.417, 'max_score': 20.568, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A20568.jpg'}], 'start': 0.782, 'title': 'Php basics', 'summary': "'php front to back part 3' delves into the basics of php syntax, encompassing variables, constants, data types, and concatenation. it targets individuals with limited php knowledge and doubles as a refresher.", 'chapters': [{'end': 69.985, 'start': 0.782, 'title': 'Php front to back part 3', 'summary': 'Covers the basics of php syntax, including variables, constants, data types, and concatenation, aimed at individuals with little to no knowledge of php, while also serving as a refresher.', 'duration': 69.203, 'highlights': ['The video series is aimed at individuals with little to no knowledge of PHP, providing a refresher on basic concepts.', 'Topics covered include basic syntax, comments, variables, constants, data types, and concatenation.', 'Encourages viewers to use Sublime Text, Atom, or Notepad++ as editors for PHP, highlighting their suitability over Windows Notepad.']}], 'duration': 69.203, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A782.jpg', 'highlights': ['Topics covered include basic syntax, comments, variables, constants, data types, and concatenation.', 'The video series is aimed at individuals with little to no knowledge of PHP, providing a refresher on basic concepts.', 'Encourages viewers to use Sublime Text, Atom, or Notepad++ as editors for PHP, highlighting their suitability over Windows Notepad.']}, {'end': 406.944, 'segs': [{'end': 160.723, 'src': 'heatmap', 'start': 70.989, 'weight': 0, 'content': [{'end': 75.592, 'text': "So what I've done here is in my HT docs folder, which is my web route.", 'start': 70.989, 'duration': 4.603}, {'end': 82.156, 'text': "I created a folder called PHP sandbox, and that's where we're gonna create our files for this series.", 'start': 75.592, 'duration': 6.564}, {'end': 91.622, 'text': "So I'm gonna create a new file here And we'll call this variables dot PHP.", 'start': 82.156, 'duration': 9.466}, {'end': 95.664, 'text': "Okay, we're gonna be looking at things other than variables, but that's the main focus.", 'start': 91.622, 'duration': 4.042}, {'end': 104.859, 'text': "So that's what I'm gonna call it alright and I'm gonna open the project up in sublime and say add folder to project and we're gonna go to.", 'start': 95.704, 'duration': 9.155}, {'end': 112.502, 'text': "let's see X amp HT docks and then PHP sandbox.", 'start': 104.859, 'duration': 7.643}, {'end': 116.864, 'text': "okay, so let's open up the variables file all right now.", 'start': 112.502, 'duration': 4.362}, {'end': 120.645, 'text': 'if I, no matter what I write in here, I can just say hello and save it.', 'start': 116.864, 'duration': 3.781}, {'end': 132.477, 'text': 'and then, if we go to HTTP localhost slash, php-sandbox slash variables dot php.', 'start': 120.645, 'duration': 11.832}, {'end': 135.339, 'text': "And we get hello, okay? I'm going to make this bigger.", 'start': 133.078, 'duration': 2.261}, {'end': 142.244, 'text': "So it's a PHP file, but we can just as well put whatever we want in here.", 'start': 137.601, 'duration': 4.643}, {'end': 143.285, 'text': 'We can put plain text.', 'start': 142.284, 'duration': 1.001}, {'end': 144.466, 'text': 'We can put HTML.', 'start': 143.325, 'duration': 1.141}, {'end': 147.828, 'text': 'So if I wrap this in h1 tags, it should still parse.', 'start': 144.986, 'duration': 2.842}, {'end': 150.771, 'text': "I'll get rid of that.", 'start': 150.15, 'duration': 0.621}, {'end': 154.782, 'text': 'So you can see that it does parse the HTML.', 'start': 151.821, 'duration': 2.961}, {'end': 160.723, 'text': 'Now if we want to write PHP, we have to surround it in PHP tags.', 'start': 156.242, 'duration': 4.481}], 'summary': 'Creating a php sandbox folder and file, demonstrating php and html parsing', 'duration': 89.734, 'max_score': 70.989, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A70989.jpg'}, {'end': 345.598, 'src': 'embed', 'start': 284.906, 'weight': 3, 'content': [{'end': 289.247, 'text': 'Okay So a variable is basically just a container.', 'start': 284.906, 'duration': 4.341}, {'end': 292.988, 'text': 'So if we save that and reload, we get our hello world.', 'start': 290.127, 'duration': 2.861}, {'end': 294.368, 'text': 'Okay Very simple.', 'start': 293.008, 'duration': 1.36}, {'end': 301.73, 'text': 'Now I want to go over the different rules of variables in PHP.', 'start': 295.668, 'duration': 6.062}, {'end': 304.391, 'text': 'All right.', 'start': 301.75, 'duration': 2.641}, {'end': 306.031, 'text': "I'm just going to put a comment here.", 'start': 304.411, 'duration': 1.62}, {'end': 316.172, 'text': 'So first rule is you have to prefix with the dollar sign in PHP.', 'start': 308.528, 'duration': 7.644}, {'end': 322.215, 'text': "You have to do that or it's going to be looked at as a constant and it's not going to work out for you.", 'start': 316.672, 'duration': 5.543}, {'end': 324.636, 'text': 'So make sure that you use the dollar sign.', 'start': 322.255, 'duration': 2.381}, {'end': 334.551, 'text': 'And then the variable itself has to start with a letter or In underscore.', 'start': 325.697, 'duration': 8.854}, {'end': 341.716, 'text': 'okay, and underscore is the only character aside from numbers and letters that you can have, and you can start a variable with it.', 'start': 334.551, 'duration': 7.165}, {'end': 345.598, 'text': "Okay, but you can't start it with a number.", 'start': 341.716, 'duration': 3.882}], 'summary': 'Variables in php require a dollar sign prefix and must start with a letter or underscore, not a number.', 'duration': 60.692, 'max_score': 284.906, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A284906.jpg'}], 'start': 70.989, 'title': 'Php basics and variable exploration', 'summary': "Covers setting up a php sandbox, creating a file named 'variables.php' to explore php basics such as variables, echo, print, comments, and data types, and emphasizes php tag usage and variable declaration rules.", 'chapters': [{'end': 132.477, 'start': 70.989, 'title': 'Php sandbox setup and variable exploration', 'summary': "Describes setting up a php sandbox in the ht docs folder, focusing on creating a file named 'variables.php' to explore various aspects beyond variables.", 'duration': 61.488, 'highlights': ["The focus is on setting up a PHP sandbox in the HT docs folder, creating a file named 'variables.php' for exploration.", 'The chapter emphasizes exploring aspects beyond variables in the PHP sandbox.', "Demonstrates opening the 'variables.php' file in Sublime and accessing it via 'localhost' for testing."]}, {'end': 406.944, 'start': 133.078, 'title': 'Php basics: variables, echo, print, comments, data types', 'summary': 'Covers the basics of php including variables, echo, print, comments, and data types, emphasizing the use of php tags for mixing php with html and the rules for declaring variables.', 'duration': 273.866, 'highlights': ['The chapter covers the basics of PHP including variables, echo, print, comments, and data types. It provides an overview of fundamental concepts in PHP, establishing a foundation for beginners.', 'Emphasizes the use of PHP tags for mixing PHP with HTML. It explains that PHP should be wrapped in PHP tags for mixing with HTML, demonstrating the versatility of PHP within web development.', 'Rules for declaring variables, including the requirement to prefix with a dollar sign and start with a letter or underscore. It outlines rules for declaring variables, emphasizing the necessity of prefixing with a dollar sign and starting with a letter or underscore, providing clear guidelines for variable declaration.']}], 'duration': 335.955, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A70989.jpg', 'highlights': ['The chapter emphasizes exploring aspects beyond variables in the PHP sandbox.', "Demonstrates opening the 'variables.php' file in Sublime and accessing it via 'localhost' for testing.", 'Emphasizes the use of PHP tags for mixing PHP with HTML. It explains that PHP should be wrapped in PHP tags for mixing with HTML, demonstrating the versatility of PHP within web development.', 'Rules for declaring variables, including the requirement to prefix with a dollar sign and start with a letter or underscore. It outlines rules for declaring variables, emphasizing the necessity of prefixing with a dollar sign and starting with a letter or underscore, providing clear guidelines for variable declaration.', 'The chapter covers the basics of PHP including variables, echo, print, comments, and data types. It provides an overview of fundamental concepts in PHP, establishing a foundation for beginners.', "The focus is on setting up a PHP sandbox in the HT docs folder, creating a file named 'variables.php' for exploration."]}, {'end': 923.237, 'segs': [{'end': 479.737, 'src': 'embed', 'start': 443.674, 'weight': 0, 'content': [{'end': 447.714, 'text': "Notice that I didn't put quotes around it because integers do not have quotes.", 'start': 443.674, 'duration': 4.04}, {'end': 450.395, 'text': "If you put quotes around it, it's going to be looked at as a string.", 'start': 447.774, 'duration': 2.621}, {'end': 456.416, 'text': 'We also have floats, which are decimals.', 'start': 451.715, 'duration': 4.701}, {'end': 461.037, 'text': "Let's say float1 and we'll set it to 4.4.", 'start': 457.256, 'duration': 3.781}, {'end': 461.517, 'text': 'Simple float.', 'start': 461.037, 'duration': 0.48}, {'end': 463.177, 'text': 'We also have booleans.', 'start': 461.537, 'duration': 1.64}, {'end': 471.815, 'text': 'booleans is a true or false.', 'start': 469.974, 'duration': 1.841}, {'end': 478.136, 'text': 'so we could say bool1 equals true.', 'start': 471.815, 'duration': 6.321}, {'end': 479.737, 'text': 'we also have arrays.', 'start': 478.136, 'duration': 1.601}], 'summary': 'Transcript covers data types: integers, floats, booleans, and arrays.', 'duration': 36.063, 'max_score': 443.674, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A443674.jpg'}, {'end': 546.443, 'src': 'embed', 'start': 509.813, 'weight': 1, 'content': [{'end': 514.235, 'text': "Let's say we want to say num2, and we'll set that to 10.", 'start': 509.813, 'duration': 4.422}, {'end': 521.818, 'text': 'And we can actually add these together if we say num1 plus num2.', 'start': 514.235, 'duration': 7.583}, {'end': 525.82, 'text': "And let's set that to a variable called sum.", 'start': 523.419, 'duration': 2.401}, {'end': 533.28, 'text': "Okay, and then let's echo out sum.", 'start': 528.439, 'duration': 4.841}, {'end': 538.481, 'text': 'Okay, so if we reload that, we get 14.', 'start': 533.3, 'duration': 5.181}, {'end': 542.582, 'text': 'And you can use, obviously, multiplication, division, subtraction, whatever you want.', 'start': 538.481, 'duration': 4.101}, {'end': 546.443, 'text': "Now let's say we want to take two strings and put them together.", 'start': 543.522, 'duration': 2.921}], 'summary': 'Demonstrating addition of numbers and concatenation of strings, resulting in a sum of 14.', 'duration': 36.63, 'max_score': 509.813, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A509813.jpg'}, {'end': 706.647, 'src': 'embed', 'start': 651.023, 'weight': 2, 'content': [{'end': 660.007, 'text': 'So if we just do greet, not greet, string one, space, string two.', 'start': 651.023, 'duration': 8.984}, {'end': 664.528, 'text': 'And then we want to echo out greeting two.', 'start': 662.247, 'duration': 2.281}, {'end': 666.589, 'text': 'Oops, I need to save it.', 'start': 664.548, 'duration': 2.041}, {'end': 670.254, 'text': 'It actually looks at these as strings.', 'start': 668.132, 'duration': 2.122}, {'end': 674.078, 'text': 'So single quotes will give you exactly what you put in.', 'start': 670.574, 'duration': 3.504}, {'end': 675.699, 'text': "It's not going to parse the variables.", 'start': 674.138, 'duration': 1.561}, {'end': 681.424, 'text': 'However, if you put double quotes and we reload, we get hello world.', 'start': 676.18, 'duration': 5.244}, {'end': 685.608, 'text': 'So the double quotes will actually parse the variable.', 'start': 681.765, 'duration': 3.843}, {'end': 693.676, 'text': 'Now, even though looking at this, this is a much easier thing to do than this, but you need to know how to do this as well, how to concatenate.', 'start': 685.728, 'duration': 7.948}, {'end': 698.324, 'text': "Alright, so the next thing we're going to look at is escape sequences.", 'start': 694.943, 'duration': 3.381}, {'end': 705.307, 'text': 'So sometimes we want to take away the special meaning that PHP gives a certain character, and to do that we can escape it.', 'start': 698.644, 'duration': 6.663}, {'end': 706.647, 'text': 'So let me give you an example.', 'start': 705.427, 'duration': 1.22}], 'summary': 'The transcript discusses using single and double quotes in php for string manipulation and escaping special characters.', 'duration': 55.624, 'max_score': 651.023, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A651023.jpg'}, {'end': 854.969, 'src': 'heatmap', 'start': 811.477, 'weight': 4, 'content': [{'end': 814.338, 'text': 'So now what I want to look at before we go is constants.', 'start': 811.477, 'duration': 2.861}, {'end': 816.278, 'text': 'Variables are just that.', 'start': 815.038, 'duration': 1.24}, {'end': 816.918, 'text': "They're variable.", 'start': 816.318, 'duration': 0.6}, {'end': 817.638, 'text': 'They can change.', 'start': 816.958, 'duration': 0.68}, {'end': 823.56, 'text': "Constants, however, you want to use for values that you absolutely know aren't going to change.", 'start': 817.738, 'duration': 5.822}, {'end': 828.041, 'text': 'An example, I guess, would be like your server name or something like that.', 'start': 824.48, 'duration': 3.561}, {'end': 830.101, 'text': "That's most likely not going to change.", 'start': 828.321, 'duration': 1.78}, {'end': 831.801, 'text': 'So you could use a constant.', 'start': 830.581, 'duration': 1.22}, {'end': 834.882, 'text': "So let's go ahead and create a constant.", 'start': 832.581, 'duration': 2.301}, {'end': 837.623, 'text': 'Now to create it, you need to use the define function.', 'start': 834.922, 'duration': 2.701}, {'end': 845.743, 'text': 'So.. We would say define and constants are a popular practice is to give them all uppercase.', 'start': 838.803, 'duration': 6.94}, {'end': 851.847, 'text': 'So if we say greeting and then the second parameter will be what we want it to be.', 'start': 846.824, 'duration': 5.023}, {'end': 854.969, 'text': "Let's say hello everyone.", 'start': 851.907, 'duration': 3.062}], 'summary': "Using constants for values that won't change, e.g. server name, using define function.", 'duration': 43.492, 'max_score': 811.477, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A811477.jpg'}], 'start': 414.09, 'title': 'Php data types, variables, concatenation, and constants', 'summary': 'Covers the basics of data types including strings, integers, floats, booleans, and arrays, emphasizing the importance of using the correct data type for different values. it also covers combining variables using arithmetic, concatenating strings, using escape sequences, and understanding constants in php. the examples include adding numbers, concatenating strings, and creating and using constants.', 'chapters': [{'end': 479.737, 'start': 414.09, 'title': 'Data types and variables', 'summary': 'Covers the basics of data types including strings, integers, floats, booleans, and arrays, emphasizing the importance of using the correct data type for different values.', 'duration': 65.647, 'highlights': ['The chapter introduces strings, integers, floats, booleans, and arrays as the basic data types in programming, emphasizing the importance of using the correct type for different values.', 'It explains that strings should be wrapped in quotes, which can be either single or double quotes, while integers do not require quotes and can be positive or negative.', 'It mentions the use of floats for decimal numbers and the representation of booleans as true or false values.', 'The chapter also introduces the concept of arrays as a data type.']}, {'end': 923.237, 'start': 479.737, 'title': 'Php variables, concatenation, constants', 'summary': 'Covers combining variables using arithmetic, concatenating strings, using escape sequences, and understanding constants in php. it includes examples of adding numbers, concatenating strings, and creating and using constants.', 'duration': 443.5, 'highlights': ["Combining variables using arithmetic The tutorial demonstrates adding numbers and concatenating strings, with an example of adding num1 and num2 to get the sum, and concatenating 'hello' and 'world' to form 'hello world'.", 'Concatenating strings using dot operator and double quotes The tutorial explains concatenating strings using a dot operator and demonstrates the difference between single quotes and double quotes in parsing variables, highlighting the ease of using double quotes for parsing variables.', 'Using escape sequences for special characters The tutorial illustrates using escape sequences to remove the special meaning of characters, with an example of escaping a single quote to ensure it is interpreted as part of the string.', 'Understanding and using constants The tutorial explains constants as values that do not change and demonstrates creating and using constants with the define function, emphasizing the importance of using constants only for values that are certain not to change.']}], 'duration': 509.147, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/0Dp7Lt7iT3A/pics/0Dp7Lt7iT3A414090.jpg', 'highlights': ['The chapter introduces strings, integers, floats, booleans, and arrays as the basic data types in programming, emphasizing the importance of using the correct type for different values.', "Combining variables using arithmetic The tutorial demonstrates adding numbers and concatenating strings, with an example of adding num1 and num2 to get the sum, and concatenating 'hello' and 'world' to form 'hello world'.", 'Using escape sequences for special characters The tutorial illustrates using escape sequences to remove the special meaning of characters, with an example of escaping a single quote to ensure it is interpreted as part of the string.', 'Concatenating strings using dot operator and double quotes The tutorial explains concatenating strings using a dot operator and demonstrates the difference between single quotes and double quotes in parsing variables, highlighting the ease of using double quotes for parsing variables.', 'Understanding and using constants The tutorial explains constants as values that do not change and demonstrates creating and using constants with the define function, emphasizing the importance of using constants only for values that are certain not to change.']}], 'highlights': ['The video series is aimed at individuals with little to no knowledge of PHP, providing a refresher on basic concepts.', 'The chapter emphasizes exploring aspects beyond variables in the PHP sandbox.', "Demonstrates opening the 'variables.php' file in Sublime and accessing it via 'localhost' for testing.", 'Emphasizes the use of PHP tags for mixing PHP with HTML. It explains that PHP should be wrapped in PHP tags for mixing with HTML, demonstrating the versatility of PHP within web development.', 'Rules for declaring variables, including the requirement to prefix with a dollar sign and start with a letter or underscore. It outlines rules for declaring variables, emphasizing the necessity of prefixing with a dollar sign and starting with a letter or underscore, providing clear guidelines for variable declaration.', 'The chapter introduces strings, integers, floats, booleans, and arrays as the basic data types in programming, emphasizing the importance of using the correct type for different values.', "Combining variables using arithmetic The tutorial demonstrates adding numbers and concatenating strings, with an example of adding num1 and num2 to get the sum, and concatenating 'hello' and 'world' to form 'hello world'.", 'Using escape sequences for special characters The tutorial illustrates using escape sequences to remove the special meaning of characters, with an example of escaping a single quote to ensure it is interpreted as part of the string.', 'Concatenating strings using dot operator and double quotes The tutorial explains concatenating strings using a dot operator and demonstrates the difference between single quotes and double quotes in parsing variables, highlighting the ease of using double quotes for parsing variables.', 'Understanding and using constants The tutorial explains constants as values that do not change and demonstrates creating and using constants with the define function, emphasizing the importance of using constants only for values that are certain not to change.']}