Hello,
I am really new at using PHP and can anyone help me out on printing a web page using Php?

Thank you.
Sam

Recommended Answers

All 2 Replies

use javascript instead... window.print(); function

Good explanations from this post

PHP cannot easily control the client's browser, except indirectly by generating Javascript which does.

The "problem" is that PHP's work is finished once it generates the page to be sent to the browser. PHP is run on the server,

Javascript, as it is normally encountered, is client-side technology, that is, it runs on the client's browser, not on the web server. (There is server-side javascript, but it only works with Netscape's server, IIRC).

You *could* work out a system where the PHP script establishes a TCP connection to the client's computer and sends a file to the client's own printer (e.g. using a combination of popen() and ssh), but

(a) there are going to be major security issues here,
and
(b) you need tight control over *both ends* of the connection (client and server); you will simply not find a solution that will work on most client's machines.

May this be informative,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.