> I need some help with functions. Does anyone know of a good place to learn
> about functions? Will someone be willing to teach me what I need to know
> functions in PHP? Thank you,

Here's a really simple example:

// regular variable that exists outside any functions
$global_var = 5;

// we will pass this variable to the function
$passed_var = 7;

// define the function
function function_name ($passed_var){

// pull in any needed global variables not local or passed to the function
global $global_var;

// regular variable that exists only in this function
$local_var = 10;

// build up the html
$html = "Now inside function_name()...<br>\n";

// build up some more html
$html .= "\$global_var + \$local_var + \$passed_var = " . $global_var +
$local_var + $passed_var . "<br>\n";

// pass the $html back to the caller
return $html;

// call the function
echo function_name ($passed_var);


Usually you wanna use funtions for code you intend to use multiple times.

Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to