php 操作 MACOS 剪下板

來源:互聯網
上載者:User

  PHP 操作 MACOS 剪下板。當然這不可能是 B/S 模式那種,操作用戶端代理(瀏覽器所在系統)的剪下板。B/S結構我們只能使用 JAVASCRIPT 或 FLASH去操作,對於PHP來講只能操作服務端。

  這裡將講的是通過調用系統 MACOS 下的 pbcopy、pbpaste 實現操作剪下板。

  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 the

  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.

  來看下簡單的使用範例,使用 exec 函數是不是很簡單?呵呵!

  /**

  * 讀取剪下板內容

  */

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

  var_dump($output, $return);

  /**

  * 寫內容(go to clipboard)到剪下板

  */

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

  var_dump($output, $return);



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.