...

View Full Version : Resolved echo function?



sitNsmile
03-28-2010, 10:59 PM
Okay trying to display all the variables in one function.

Where I'd like to echo the entire function.

echo $userData->collectUserData();



public function collectUserData(){

$this->getUserIp();
$this->getUserBrowser();
$this->getUserCountry();
$this->getUserReferral();

return $this;

}


and my results (output) just says "Object id #3"

and if I do

echo $userData->getUserIp();
That works, but that's not what I want to do.

Thanks

MattF
03-28-2010, 11:07 PM
public function collectUserData(){
$array = array();

$array[] = $this->getUserIp();
$array[] = $this->getUserBrowser();
$array[] = $this->getUserCountry();
$array[] = $this->getUserReferral();

return $array;

}

JAY6390
03-28-2010, 11:52 PM
You could also implode the data into a string from the array that MattF has supplied so that the echo will display it all (perhaps using a <br /> as the glue)

sitNsmile
03-29-2010, 04:09 AM
public function collectUserData(){
$array = array();

$array[] = $this->getUserIp();
$array[] = $this->getUserBrowser();
$array[] = $this->getUserCountry();
$array[] = $this->getUserReferral();

return $array;

}


every time I try this "array" out, no matter where I place it. all the output comes out is the word "Array"

tomws
03-29-2010, 04:45 AM
That's because it's ... an array. Pull the component using indexes 0, 1, 2, 3, or follow Jay's advice.

JAY6390
03-29-2010, 11:20 AM
public function collectUserData(){
$array = array();

$array[] = $this->getUserIp();
$array[] = $this->getUserBrowser();
$array[] = $this->getUserCountry();
$array[] = $this->getUserReferral();

return implode('<br />', $array);

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum