Php MACOS clipboard operation

Source: Internet
Author: User
Use PHP to operate the MACOS clipboard. Of course, this cannot be the B/S mode, which is used to operate the clipboard of the client proxy (the system of the browser. The B/S structure can only be operated using JAVASCRIPT or FLASH. for PHP, only the server can be operated. Here we will talk about it through... "> <LINKhref =" http://www.php100.com//stat

Use PHP to operate the MACOS clipboard. Of course, this cannot be the B/S mode, which is used to operate the clipboard of the client proxy (the system of the browser. The B/S structure can only be operated using JAVASCRIPT or FLASH. for PHP, only the server can be operated.

Here we will talk about the operation of the clipboard by calling pbcopy and pbpaste under the system MACOS.

Pbcopy takes the standard input and places it in the specified pasteboard. If no pasteboard is specified, the general pasteboard will be used by default. The input is

Placed in the pasteboard as plain text data unless it begins with the Encapsulated PostScript (EPS) file header or the Rich Text Format (RTF) file header, in which case

It is placed in the pasteboard as one of those data types.

Pbpaste removes the data from the pasteboard and writes it to the standard output. It normally looks first for plain text data in the pasteboard and writes that to

Standard output; if no plain text data is in the pasteboard it looks for Encapsulated PostScript; if no EPS is present it looks for Rich Text. If none of those types

Is present in the pasteboard, pbpaste produces no output.

Let's take a look at the simple example. Is it easy to use the exec function? Haha!

/**

* Read clipboard content

*/

Exec ('pbpaste ', $ output, $ return );

Var_dump ($ output, $ return );

/**

* Write content (go to clipboard) to the clipboard

*/

Exec ('echo go to clipboard | pbcopy', $ output, $ return );

Var_dump ($ output, $ return );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.