|
akhtardaha@gmail.com - 20 Aug 2008
thats great. very nice guidance is provided here.
i am really impressed.
A PHP User - 20 Aug 2008
Ooohhhhhhh. Phil nice one :)
Steve - 20 Aug 2008
Thank you Phil. I had no idea what Paul was getting at without your help. This FREE book is much appreciated, though!
ajekigbe - 20 Aug 2008
To: A PHP User,
I think he commucates.
"Parentheses" are also "Brackets".
"[]" = Square Brackets.
"<>" = Angle Brackets.
May be "()" = Circle Brackets I am not sure!
A PHP User - 20 Aug 2008
fun reading so far! however, what you call "brackets" are actually "parentheses": '()' are parentheses, '[]' brackets, and '<>' angle brackets. ;)
Btw0 - 20 Aug 2008
You made things just so easy.
Greets from People's Republic of China.
Phil Resch - 20 Aug 2008
To l_padmapriya@rediffmail.com:
The somefunc example, using $foo and $bar, is meant to show you differences in how you can pass information into your function.
He shows two basic ways: pass-by-value (passing a copy of your variable that only exists within the function) and pass-by-reference (passing the actual variable).
Let's look at the third example:
somefunc($foo, &$bar);
The first parameter is being passed by value, so we're sending a copy of $foo into the function. The second parameter is being passed by reference, so we're sending $bar (the actual thing, not just a copy) into the function.
And let's say that we've defined $foo = 3 and $bar = 6. And let's also say that within somefunc() are the lines reading
$foo++;
$bar++;
So when we call somefunc() with $foo and $bar ...
Inside of the function the ++ operator will increment the copy of $foo, so the copy of $foo == 4.
The ++ operator will increment the actual $bar variable, so $bar == 7.
Then all of the code inside of somefun() finishes execution, and we leave the function. The copy of $foo gets destroyed, because it existed only inside of the function.
So after somefunc() executed we're left with $foo == 3 (because the original was never changed, only a copy of it was changed) and $bar == 7 (because the original was changed inside of the function).
Phil Resch - 20 Aug 2008
To l_padmapriya@rediffmail.com:
The somefunc example, using $foo and $bar, is meant to show you differences in how you can pass information into your function.
He shows two basic ways: pass-by-value (passing a copy of your variable that only exists within the function) and pass-by-reference (passing the actual variable).
Let's look at the third example:
somefunc($foo, &$bar);
The first parameter is being passed by value, so we're sending a copy of $foo into the function. The second parameter is being passed by reference, so we're sending $bar (the actual thing, not just a copy) into the function.
And let's say that we've defined $foo = 3 and $bar = 6. And let's also say that within somefunc() are the lines reading
$foo++;
$bar++;
So when we call somefunc() with $foo and $bar ...
Inside of the function the ++ operator will increment the copy of $foo, so the copy of $foo == 4.
The ++ operator will increment the actual $bar variable, so $bar == 7.
Then all of the code inside of somefun() finishes execution, and we leave the function. The copy of $foo gets destroyed, because it existed only inside of the function.
So after somefunc() executed we're left with $foo == 3 (because the original was never changed, only a copy of it was changed) and $bar == 7 (because the original was changed inside of the function).
MrGonzy - 20 Aug 2008
Really good online book.
I had c++ in highschool and I have to say that i learn a lot and very quick here.
Things for me to do: Buy your book !!!
Thanks
And greets from Belgium
l_padmapriya@rediffmail.com - 20 Aug 2008
The example foo, bar function confuse me litte bit. can you help me?
Learning PHP - 20 Aug 2008
Wow, I'm surprised how much like C++ PHP is, it's great.
For Jordan:
The function call at the top of the page is a little confusing but I think that was done to show PHP's capability to use function return values as arguments in another function.
For example:
func1(func2(func3(), func4()));
func1() in this case takes 1 argument which is the value returned by func2. func2 can take 2 arguments which are the values returned by func3() and func4() and must be evaluated inside func2() before it can be used as an argument in func1. You can tell all this because of the way the parenthesis are placed.
If you changed func1 to accept 2 parameters and func2 to accept 1 parameter the syntax would look something like this.
func1(func2(func3), func4());
I hope this helps Jordan.
Jordan - 20 Aug 2008
Hmmm... this page has confused me somewhat.
A PHP User - 20 Aug 2008
Great tutorials so far.
Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.
If you are reporting an error in the content, please tell me directly.
|