Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
call by name and call by value - PHP

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.

Associated topic - PHP - Functions

Next ... random image ... a slide show ... image from list below


© WELL HOUSE CONSULTANTS LTD., 2009: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho