Fatal error: Call to undefined function printer_open()

Refaat picture Refaat · Oct 3, 2013 · Viewed 8.8k times · Source

I'm trying to print some string using PHP, i'm using the PHP print functions:

$printer = ("HP LaserJet Professional P1102");
$handler= printer_open($printer);
$content="Test Content";
printer_write($handler, $content);
printer_close($handler);

but I got that error :

Fatal error: Call to undefined function printer_open() in C:\xampp\htdocs\print.php on line 12

after googling it i found that i must add the php_printer.dll to the extensions file in php and add it's extension to the php.ini file, then restarting the server services, all of that accomplished but still getting that error. p.s. I've tried it on WAMP and XAMPP

Answer

geekdev picture geekdev · Oct 3, 2013

I think solution would be extension location.php_printer extension should be stored in c:\xampp\php\ext and not in c:\xampp\php. So move it to the ext-folder, and restart Apache.

Can you look into the error_log, which tells you, if it fails to load the module. You should also run a phpinfo(), which shows up all loaded modules, you must find the printer extensions there.

I hope it may resolve your issue.