MyBB Community Forums

Full Version: PHP Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working on writing a system that deals with templates, and I am using {image:filenamehere.jpg} to represent an image.. now I have these images in a folder and wrote a function to rename files with the correct folder, so now I was trying to use that function in my new function that replaces the {image:blah.jpg} with the location of the file so it could be used in a <img /> tag... if you get what I mean, but I cannot use the function in that class because its in the same class...? I get an error... The problem lays in process_image function where I call to the get_image_location function which is in the same class... and php I guess can't do that so I was wondering could someone help me figure out how to do it, with keeping both functions in the same class?

Here is my code:
/* Write the main class */
class splash {
	/* Function: get_image_location */
	function get_image_location($attribute) {
		require("settings.php");
		return $settings['imagefolder'] . $attribute;
	}
	/* Function: process_images */
	function process_images($attribute) {
		$location = preg_replace("/\{image:(.*?)\}/si", "$1", $attribute);
		$location = $splash->get_image_location($location);
		return $location;
	}
}
$splash = new splash();

Error:
Notice: Undefined variable: splash in C:\server\www\splash2\core.php on line 31

Fatal error: Call to a member function get_image_location() on a non-object in C:\server\www\splash2\core.php on line 31
Change this:

$location = $splash->get_image_location($location);

To this:

$location = $this->get_image_location($location);