| | I want my site (with PHP) to enable PRINT command. The usual print, with printer as output I mean. So, how can I do it? I've seen my college site use ASP and they can give me a PRINT xommand box, when I click it the printer will print the page. |
|
|
Take a look at the Printer Functions reference. These apparently only work on certain versions of Windows, and require additional PECL extensions (I have not tested any of these functions, and therefore cannot really comment).
There's an example on the print() function listing for sending output to a printer (note that the print() function simply displays output), apparently taken from Tufat.com. This example is also on Windows, and at a glance, appears to utilize Acrobat Reader, Microsoft Word or Microsoft Excel to do the actual printing.
isnt is easier to have it in javascript? (you can always escape it into a PHP echo if you really insist)..
HTML <a href="java script:window.print()">Print</a> nothing wrong with simple stuff
Yes, doing that in javascript would be a lot easier considering you can add javascript above or below your
<?php tag. That's the great thing about php. You could also make it print with a button, not just a link.
The example in the print() command reference calls a COM event to trigger the printing, which is similar to how JavaScript operates - however, PHP is server-side, JavaScript is not. I don't think .hack//GU simply wants to print the current page rendered by the browser.
You push ctrl p or for apple the little wierd sign with the apple next to it then p.
The example in the print() command reference calls a COM event to trigger the printing, which is similar to how JavaScript operates - however, PHP is server-side, JavaScript is not. I don't think .hack//GU simply wants to print the current page rendered by the browser. That is why I mentioned escaping into PHP... as in CODE <?php echo "<a href=\"java script:window.print()\">Print</a>; ?> or what ever way of returning you happen to want to use...
Ok, now let's review what that does: causes the script to output a simple JavaScript statement in plaintext which the visitor's browser will then interpret as it will, which is exactly the same as adding it in the HTML. It isn't going to execute anything at the server's end, and solves little.
I think one (or more?) of us is misunderstanding .hack//GU's problem here. I'm assuming he wants to send output to the printer at the server, not the client. JavaScript has no control over the server whatsoever. All the window.print() function will do is cause the browser the visitor is using (assuming it supports JavaScript) to print the current webpage, with nothing happening at the server's end whatsoever. I don't know why you would want to use PHP to print anything in the first place, but as .hack//GU posted it in the PHP programming forum, I'm assuming that is what he is after. The usual print, with printer as output I mean. I take that as wanting the user to be able to print - with a printer - the page he is viewing. Perhaps .hack//GU would like to correct me? The reason I would do it in PHP is that then you can have it inside a logic syntax, which is rather handy... but then I am probably just too noobish to understand your advanced methods of thinking, arn't I? Also about escaping in PHP - dont use heredoc syntax, even if it is easier... This: CODE <?php echo '<a href="java script:window.print()">Print</a>'; ?> Will produce the exact same result as simply placing: CODE <a href="java script:window.print()">Print</a> Somewhere in the HTML. All your code is doing is outputting the text. It doesn't use PHP to print at all. Just JavaScript. No PHP. JavaScript only. PHP is not being used. JavaScript is. PHP does nothing here. JavaScript does everything. Outputing code as text does not cause it to be executed in any form; you cannot combine JavaScript and PHP to operate together at a server-level as JavaScript is client-side, and only operates from within the user's browser (if it supports JavaScript, of course). Just to re-iterate: what you are suggesting does not use PHP at all. [edit] For some reason (security?), the IPB code parser is insisting that 'javascript' become 'java script'. There should not be a space in the link.
Latest Entries
wee then we are all happy then, and since .hack//GU is not really taking part, I guess we solved his problem somewhere along the line. If so, why the hell are we discussing this?
I seem to remember suggesting how to physically print with PHP in the first post I made in this thread - the only post which, might I point out, actually addressed the problem exactly as .hack//GU described it.
I'm not saying there is never a benefit to dynamically displaying JavaScript code. If you read my previous post, I said 'In this case, there is absolutely no benefit...'. Yet you continue to insist there is. I'm glad you find my refusal to agree with pointlessly wasting time and inability to build an empty argument on that 'hilarious'. I share a similar view of your inability to grasp logic and reason.
lol, doesnt have to be double quotes, if you insist - but I dont think that one line of code will greatly influence parsing time unless you have a freaking slow server and a 5 bps server.
But say you have this huge page of code, with a switch on $page_id, and heredoc constructs for page output. Obviously, if you put the JS as plain html, it will appear on every single page which the switch concerns - This may not be very desirable, so you would then put it in PHP. Please, try to look from a different point of view. I am not saying that the result is any different from just plain html, or that PHP would be the one doing the printing. All I am saying - and ask Moldboy, who seems to understand my point - is that there is a benefit in putting it inside PHP. Even though PHP would not do the actual printing. And even though it could be done with just plain html/JS... I agree that this is getting silly, but I still find it hilarious that you have not grasped the point yet. But is .hack//GU even following this post? In the time we have spent arguing, he has most likely finished his site and started selling like heill... I really would like to finish my own, you know.... Moldboy, you obviously did not read the whole thread properly. But Spectre, you did not answer my question: Do you have a better PHP way of doing it?
*Sigh. Here we go again. Despite saying my previous post would be my last in this topic..
moldboy, please don't argue just for the sake of arguing. This is getting ridiculous and childish. Outputting JavaScript via PHP involves PHP doing nothing outside of sending the data as output; it has absolutely no influence over nor is it all influenced by how the outputted JavaScript operates. Obviously, having PHP send output is using PHP; I was referring to the fact that it is not using PHP to instigate whatever operation the JavaScript will then execute. In this case, there is absolutely no benefit in having PHP send JavaScript as output over simply having it contained staticly within a file - quite the opposite in fact, it will result in further processing power being required in order to have the PHP output a non-dynamic piece of plaintext, especially if you use doublequotes as elrohir suggested. Illogical, pointless things frustrate me no end.
No offence, but you two are nuts, you're not even arguing and yet seem to think that you are. One says you can't print with PHP (atleast not for the client) And the other one say that PHP doesn't parse javascript code. Both very good points, and very true, however they don't confict.
Now QUOTE Echoing JavaScript with PHP does not use PHP at all yes it does, if you do something with php it uses php when you write echo "some JS code"; it uses php, it just does. QUOTE I don't know why you would even suggest outputting JavaScript from PHP as a method that uses PHP, because it doesn't. again if you use php to echo something then you DO use php, and why, perhapse elrohir felt it would be a good idea if .hack//GU knew you could enclose javascript inside the echo statement, and perhapse then bu knowing that .hack//GU would be able to have something which would only offer the print command to users who were signed in soCODE //set user logged in state $loggedin = TRUE; //determin output based on previous decision if ($loggedin ==TRUE){ echo "the print command (I don't do JS)"; } else { echo "I'm sorry the print option is only available to registered users" }
Similar Topics
Keywords : command
Hey im trying to restart apache throug a script and so far none of the php or perl scripts have **YOU DO NOT NEED ANY HTML TAGS FOR THIS SCRIPT**** Enter all values between the ' ' quotes Looking for make, print, command
|
|
![]() Question: Anybody Know How To Make Print Command? |
| ADD REPLY / Got an Opinion! | Remove these ADs! | RAPID SEARCH! | Free Web Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|