Fatal Error: Call to undefined function _()

8.9k Views Asked by At

I'm trying to use this php class on my CUPS Server.

Now when I try to call a function from this class, i get
Fatal error: Call to undefined function _() in /usr/local/share/php/printipp/BasicIPP.php on line 344

Line 344 Looks like this:

self::_putDebug(sprintf(_("Charset: %s") , $charset) , 2);

Inside the following function:

 public function setCharset($charset = 'us-ascii') 
{
 $charset = strtolower($charset);
 $this->charset = $charset;
 $this->meta->charset = chr(0x47) // charset type | value-tag
  . chr(0x00) . chr(0x12) // name-length
  . "attributes-charset" // attributes-charset | name
  . self::_giveMeStringLength($charset) // value-length
  . $charset; // value
 self::_putDebug(sprintf(_("Charset: %s") , $charset) , 2);
 $this->setup->charset = 1;
}

My PHP Version is 5.3.26. What is the _() function and how am i missing it?

EDIT**
It looks like _() is an alias for gettext().
After checking with package manager i have 0.17 Version Of Gettext installed.
How do i enable it in php?

1

There are 1 best solutions below

0
On

This error message appears because the gettext extension has not been enabled in PHP.

You can check this with a phpinfo() where there should be a table for gettext which contains a row: GetText Support - enabled
If you can only find an entry in the PHP Credits table - it's not enabled.

It can be enabled by adding extension=gettext to php.ini.