output to printer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Gavski
Forum Newbie
Posts: 19
Joined: Thu May 16, 2002 2:30 pm
Location: UK

output to printer

Post by Gavski »

I need to send data to my printer in php and got this code snippet from php site

$handle = printer_open("EPUSB1:Epson stylus 580");
printer_write($handle, "Text to print");
printer_close($handle);

I keep getting error:-undefined function printer_open(), as if php doesn't recognise printer_open();

Any Ideas??

Thanks.
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

Well my guess was that you have to enable it in the 'php.ini', but the manual doesn't say so. But it did say this:
These functions are only available under Windows 9.x, ME, NT4 and 2000. They have been added in PHP 4 (4.0.4).

http://www.php.net/manual/en/ref.printer.php
User avatar
Gavski
Forum Newbie
Posts: 19
Joined: Thu May 16, 2002 2:30 pm
Location: UK

mmmm

Post by Gavski »

Yea, I checked my php.ini and printer is enabled I also have v4.12. I'm asuming that if 4.04 has these functions then 4.12 should also, I'm running win Me.

I would have asumed that sending output to a printer is a fairly basic opreation but I can't find much info on it.?
thanks anyway.
banks1850
Forum Newbie
Posts: 3
Joined: Sun Jun 22, 2003 7:05 am
Location: Boston area

printing with php

Post by banks1850 »

Gavski,
make sure you have the dll in the extensions folder of your php
root folder, if it isn't in there you won't be able to use it even if
you enable php_printer.dll in your php.ini file.

I had that same issue, and this fixed it.

also make sure you are using the right precursor

above the extensions area in your php.ini file there is a entry that looks like this:


; Directory in which the loadable extensions (modules) reside.
extension_dir = ./

if you are using linux or unix for your web server, then this should be ok
but if you are using windows
it should look like this
extension_dir=<path to php/extensions/>

if this was set up incorrectly then you will get an error on starting apache or what ever web server software you use. Just a few things to note, also make sure (I know this sounds obvious but...)you restart the webserver after you change the php.ini file or none of the changes will take effect.
Post Reply