Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
PHP Built-Ins and Documentation2:26 with Hampton Paulk
PHP has tons of built in functions to make your life as a PHP developer so much better, but first we need to know how to find them and how to read the docs. Let's jump in.
[MUSIC] 0:00 PHP has tons of built in functions to make your life as a PHP developer so 0:05 much better. 0:09 But first, we need to know how to find them, and how to read the docs. 0:11 So let's jump in. 0:14 Okay, so, from Google search I'm just gonna type in PHP built in. 0:16 Okay, built in functions, and 0:23 our first result should be PHP internal built in functions manual. 0:26 So you'll see this is gonna take us to php.net/manual/en for 0:30 English, and then functions internal PHP. 0:35 If you look at the second paragraph, 0:38 there's a section here that says, how to read a functions definition. 0:39 So taking a look at this we understand our data types. 0:44 We've gone over that in a previous lesson. 0:48 So what we're gonna look at is how it is defined. 0:51 So for instance, we're looking at string length as our first example. 0:54 So what you'll see, is that there is a function name, 0:58 then it will show you when it's been around, so it's been in PHP4 and PHP5. 1:02 It's going to return an integer value, so you'll see here it says int strlen length, 1:07 and then inside of that, it'll show you the argument you pass through. 1:13 It starts by showing you what kind of argument it expects. 1:18 So it expects a string, and then you pass through a variable, and 1:21 in this case it just says, string. 1:24 So then, it tells you the result. 1:27 It'll say it will return the length of a given string. 1:30 So that's a very, very simple way to look at the docs. 1:34 Let's look at string length actually defined. 1:37 There's actually a link right up here to it. 1:40 And then we can see how the docs actually look to us. 1:42 So you'll see here under strlen, we see PHP 4, PHP 5, 1:46 and then a quick description which just says, get string length. 1:51 Then, what it expects. 1:56 Int means it expects an integer, then you have the keyword, 1:57 which is strlen, which is the actual function. 2:01 Then the arguments that you pass through have to be a string, and then you 2:04 just pass through a single argument that is required, dollar sign, string. 2:07 It'll return to you, the length of the given string as an integer. 2:11 So that's a very basic example of how to read the documentation. 2:16 Now, we're gonna do some more, starting with how to look at string functions. 2:21
You need to sign up for Treehouse in order to download course files.Sign up