scanreg Posted October 9, 2008 Share Posted October 9, 2008 Am just starting to learn PHP ??? I have the following function: function dino($fred) { return $fred *= 2; } $wilma = 6; $barney = dino($wilma); echo "\$wilma is: $wilma<br />"; echo "\$barney is: $barney"; If you have $wilma = 6; why isn't it $wilma above in the function instead of $fred ? In other words, how does the script/php know to insert the value of $wilma into the function if it's $fred that is mentioned in the function, not $wilma ? Many thanks Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/ Share on other sites More sharing options...
Brandon Jaeger Posted October 9, 2008 Share Posted October 9, 2008 $fred is just a value of whatever is being sent through the function header. Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/#findComment-660919 Share on other sites More sharing options...
scanreg Posted October 9, 2008 Author Share Posted October 9, 2008 I see, it's kind of a place holder (I think) Thanks Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/#findComment-660933 Share on other sites More sharing options...
philipolson Posted October 9, 2008 Share Posted October 9, 2008 See also: http://php.net/functions Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/#findComment-660960 Share on other sites More sharing options...
PFMaBiSmAd Posted October 9, 2008 Share Posted October 9, 2008 The parameter name in the function definition is the variable name that the function will use to reference that parameter inside the function. When the function is called, the parameter can be supplied from anything - string, number, expression, variable, or another function call. Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/#findComment-661013 Share on other sites More sharing options...
scanreg Posted October 9, 2008 Author Share Posted October 9, 2008 Super thanks, will eventually understand this stuff Link to comment https://forums.phpfreaks.com/topic/127713-newbieq-passing-value-to-function/#findComment-661045 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.