CakePHP - Call model function from another function within in the same model

cakephp, model, php

Solution

You simply need to call the other function like:

$host = $this->getHostFromURL($url);

Problem

I've got a CakePHP model with a few functions in it working well. Now I'm trying to write a new function that uses a few of the functions I've already written. Seems like it should be easy but I can't figure out the syntax. How do I call these functions I've already written within my new one? Example: ``` <?php public function getHostFromURL($url) { return parse_url( $http.$url, PHP_URL_HOST ); } public function getInfoFromURL($url) { $host = getHostFromURL($url); return $host; } ``` Result: Fatal error: Call to undefined function getHostFromURL() in /var/www/cake/app/Model/Mark.php on line 151 I also tried something like: ``` <?php public function getHostFromURL($url) { return parse_url( $http.$url, PHP_URL_HOST ); } public function getInfoFromURL($url) { $host = this->Mark->getHostFromURL($url); return $host; } ``` But got the same result. Obviously my functions are much more complicated than this (otherwise I'd just reuse them) but this is a good example.

Original source