Passing a function argument to another function
Posted: Tue Mar 14, 2006 8:51 pm
feyd | Please use
Basically, I need $abc to be passed to fctFunction2, worked on, then returned as a dependant variable $txtVariable, and finally, printed in fctFunction1.
Whew, hope that makes sense. Please help.
Clinton
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi all,
I'm new to PHP and MySQL...
I need help on variable scope and passing a function argument to another function and returning a variable. I'm missing something so my code is not working.
I have a class (the theory of what I'm doing):Code: Select all
class myClass(){
var $arrArray1 = array ("A", "B", "C");
var $arrArray2 = array ("1", "2", "3");
var $txtVariable = fctFunction2($abc);
function fctFunction1() {
foreach ($this->arrArray1 as $abc) {
// ** send $abc out as a variable here to fctFunction2
echo "blah blah: ".$abc; // Simple. Works. Variable in this function
echo "blah blah: ".$this->txtVariable; // doesn't work
}
}
function fctFunction2($xyz) {
if $xyz = "A" {
$this->txtVariable = "apple.php";
} else {
$this->txtVariable = $xyz.".php"; // so B.php or C.php
return $this->txtVariable;
}
}
$objObject = new myClass();
$objObject -> fctFunction1();Whew, hope that makes sense. Please help.
Clinton
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]