PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
WaldoMonster
Forum Contributor
Posts: 225 Joined: Mon Apr 19, 2004 6:19 pm
Contact:
Post
by WaldoMonster » Sat Jul 03, 2004 9:48 am
Sometimes I see functions like this:
Code: Select all
<?php
Function (&$some_value)
{
// Do something
}
?>
Where is the & symbol for?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jul 03, 2004 9:50 am
reference.. basically, $some_value will be a pointer, if you're familiar to that term, to the data passed. The function is able to directly modify the content of the data passed to it, so it could return lots of extended data..
WaldoMonster
Forum Contributor
Posts: 225 Joined: Mon Apr 19, 2004 6:19 pm
Contact:
Post
by WaldoMonster » Sat Jul 03, 2004 10:08 am
Is this the purpose of the reference?
Where can I find some more information about pointers and reference?
Code: Select all
<?php
function AddMonster(&$name)
{
$name .= 'Monster';
}
$name = 'Waldo';
AddMonster($name);
echo $name; //returns WaldoMonster
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jul 03, 2004 10:10 am
that's exactly the use.
[php_man]references[/php_man]
WaldoMonster
Forum Contributor
Posts: 225 Joined: Mon Apr 19, 2004 6:19 pm
Contact:
Post
by WaldoMonster » Sat Jul 03, 2004 10:20 am
Thanks for the help.
Now it is comming back to me.
It works the same way as Turbo Pascal, that is a long time ago
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Jul 03, 2004 3:33 pm
omg pascal........ the pain.
i remember in grade 10 i made slimmer