views:

88

answers:

1

Hi

I have a CodeIgniter application, but one of my controllers must call a data processing function that I have also written myself. The only problem is I can't seem to figure out how to do this. Looking through the user guide it seems that I should put my function inside the class declaration, and prefix it with an underscore (_) so that it cannot be called via the url. However, this is not working. Here's an example of what I mean:

<?php
class Listing extends Controller
{
    function index()
    {
     $data = "hello";
     $outputdata['string'] = _dprocess($data);
     $this->load->view('view',$outputdata);
    }
    function _dprocess($d)
    {
     $output = "prefix - ".$d." - suffix";
     return $output
    }
}
?>

The page keeps telling me I have a call to an undefined function _dprocess()

How do I call my own functions?

Thanks!
Mala

Edit:
I've gotten it to work by placing the function outside of the class declaration. Is this the correct way of doing it?

+1  A: 

This line is creating problem for you:

$outputdata['string'] = _dprocess($data);

Replace with:

$outputdata['string'] = $this->_dprocess($data);
Sarfraz
Thank you very much :)
Mala
you are welcome man
Sarfraz