Page 1 of 1

Calling methods in the same class problem

Posted: Wed Dec 27, 2006 2:31 am
by afbase
ok, If I have a class, how do have method two call method one??? I just cut out a part of my class for example:

Code: Select all

class example{
var $bookval;

function set_bookval($number){
$this->bookval=$number;
}

function mysql_bookval($ticker){
	$url = "http://www.investor.reuters.wallst.com/stocks/Ratios.asp?rpc=66&ticker=".$ticker;
	$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$url);
		curl_setopt($ch, CURLOPT_FAILONERROR, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch, CURLOPT_TIMEOUT, 3);
	$result = curl_exec($ch);
		curl_close($ch);
	$pattern='!Price to Book \(MRQ\)</span>\s*<span class="rb-company greycell">([^<]*)</span>!';
	preg_match($pattern,$result,$bookval);
	set_bookval($bookval[1]);
}
}

I get a mean little error if i try calling another method in the same class. Any ideas????
Fatal error: Call to undefined function set_bookval() in /home/clinton/hdd1/coldowl/project/stock/tests/stock_class.php on line 82

Posted: Wed Dec 27, 2006 3:03 am
by timvw
That should be $this->set_bookval($bookval[1]); instead...

Posted: Wed Dec 27, 2006 6:19 am
by Ollie Saunders
the php manual loves you if you read him
Edit: if ($youLike) str_replace('him', 'her', $myPost);