Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

method of calling phpBB functions 1

Status
Not open for further replies.

Ferrian

Programmer
Sep 7, 2005
53
GB
Hello all.

I have been teaching myself PHP for a while now and am finally at a stage where I am trying to put together a web forum written from scratch in PHP. I have been reading the phpBB code to try and understand everything that it does so that I can include as much functionality in my own forum as possible (I don't want to just copy and paste though, I want to understand it).

I repeatedly keep running into a piece of code which appears to be calling a function from the template.php page, yet I don't understand why it works (I come from an ASP background, so it could just be a clash of understanding).

The function in includes/template.php:
Code:
function set_filenames($filename_array)
{
	if (!is_array($filename_array))
	{
		return false;
	}
	reset($filename_array);
	while(list($handle, $filename) = each($filename_array))
	{
		$this->files[$handle] = $this->make_filename($filename);
	}
return true;
}
How it is called in posting.php:
Code:
[blue]$template->set_filenames[/blue](array(
	'confirm_body' => 'confirm_body.tpl')
);
Could someone explain how this is calling the function, since it has $template on the front, and what the meaning of the '->' is?

Thanks :)
 
the function set_filenames() is inside a class, I suspect. It is a method of an object which you have called $template. I suspect that somewhere above this line there is a statement similar to

require_once template.php;
$template = new HTML_TEMPLATE;

thus the -> operator is an object assignment operator.

search google or php.net for object oriented programming to get a fuller understanding. Most people find objects a neat way of doing things. for myself I perfer procedural code for the most part, but still my reusable code libraries are based on oop.
 
Thanks, I think that has set me on the right path :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top