Re: functions and variables ..
| From: | David Newcomb | Date: | Thu, 14 Sep 2000 12:11:00 +0000 |
| Subject: | Re: functions and variables .. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16757@lists.php.net to get a copy of this message | ||
> I've just started with classes and still strugling a bit ..
> so i'm trying to do functions that can easely be moved over to be used in
classes ..
> so I have 3 functions ..
> font_gen(), bg_gen(), and create_template()
> font_gen takes 3 variables and bg_gen 3 variables as well
> font_gen and bg_gen returns an array with data, while
> create_template uses the arrays from font_gen and bg_gen to create the
template.
> so create_template calls both font_gen and bg_gen to create template
> here is mock up
>
> function font_gen($var1,$var2,$var3{
> return $font
> }
>
> function bg_gen($var4,$var5,$var6{
> return $bg
> }
>
> functions create_template($var7){
> font_gen();
> bg_gen();
> print" blah blah font_gen data and bg_gen data";
>
> }
> do i have to pass the font_gen and bg_gen variable thru create_template as
well .. or will it be able to see it
try:
functions create_template($var7)
{
$fg=font_gen();
$bg=bg_gen();
print" blah blah $fg data and $bg";
}
> it would just be easer to assign the values of $var1-6 in my php file then
include the functions and run then
> rather then to have to pass the variable thru create_template to get
font_gen and bg_gen to run
Also have a look at the global keyword in conjuction with array()s
hope this helps,
David.