/    Sign up×
Community /Pin to ProfileBookmark

Reading the PHP manual (&$varname)

Hi,

In the PHP manual, if you take a look at, for example, fsockopen:

Description
resource fsockopen ( string target [, int port [, int &errno [, string &errstr [, float timeout]]]] )

Note how errno and errstr both have ‘&’ preceding them. Does the ‘&’ symbol indicate that this paramater is simply a ‘container variable’ to be provided by the coder?

If so, what is the proper term for this?

Thanks.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@felgallOct 12.2006 — See http://au2.php.net/manual/en/language.references.pass.php for information on pass by reference (as compared to pass by value which doesn't have the &).
Copy linkTweet thisAlerts:
@callumdauthorOct 12.2006 — To be clear,

Does pass by value mean I'll actually put a real value (not a variable) in to the function call?

Eg,

function_name('Hello my name is Tom'); <-- Pass by value?
Copy linkTweet thisAlerts:
@NogDogOct 12.2006 — To be clear,

Does pass by value mean I'll actually put a real value (not a variable) in to the function call?

Eg,

function_name('Hello my name is Tom'); <-- Pass by value?[/QUOTE]

No, it means that the value -- either the literal value as in your example or the value of the variable -- will be passed to the function. The receiving variable will therefore have a local scope only within the function. Any changes made to it will have no effect on any variables of the same name outside of the function (whereas when you pass it by reference, any changes affect the value of the variable that was passed to the function both within and outside of the function, similar to declaring a variable as "global" within a function).
Copy linkTweet thisAlerts:
@callumdauthorOct 12.2006 — I get it.

Thanks NogDog.
×

Success!

Help @callumd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...