| |||||||||||
| |||||||||||
call by name and call by value - PHP
![]()
In PHP, functions can collect parameters "by name" and "by value". A parameter collected by VALUE is copied into
teh function; this means that the function can be called with an expression in the call, and that the function
itself can change the value of the variable it gets copied into without altering the value in the calling code -
so this is a safe way to handle parameters. By contrast, a parameter collected by NAME isn't copied - the
parameter variable within the function is simple a second name for the variable in the main code; this means that
such parameters cannot be expressions in the main code, and any alterations made within the function will also
alter the contents of the variable in the main code. In general, you'll define your functions to collect by value
most of the time, reserving "call by name" for the minority of cases where you need to alter the calling variable.
Show a large image More about function parameters Associated topic - PHP - Functions |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||