Jump to content

&$ in a function declaration


Marrvel

Recommended Posts

Hello everybody,

I'm working on a credit card validation but that's not important. While looking at some other peoples scripts for inspiration I found on with this syntax in the function declaration:

[code] checkCreditCard ($cardnumber, $cardname, &$errornumber, &$errortext)[/code]

all i want to know is why  are there &'s in front of the last 2 variables? what does it do? I've never seen it used before.

Cheers
Rob
Link to comment
Share on other sites

The ampersand means that the value of the variable is being assigned by reference. I use the same CC function you posted. I also had the same question when I stumbled across the ampersand. Below is the link to my previous post which explains the "assign by reference" and how to use it with this function. In addition, I also posted the link to the php manual that explains variables.


my previous post - http://www.phpfreaks.com/forums/index.php/topic,110130.0.html

php manual - http://us3.php.net/language.variables

Best,

Fezzik
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.