検索
ホームページphp教程php手册php调用Linux系统常用命令

php调用Linux系统常用命令

Jun 06, 2016 pm 07:52 PM
lilinuxphp注文よく使われるシステム移行入力

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 1、exec函数 ?php $test = "ls /tmp/test"; //ls是linux下的查目录,文件的命令 exec($test,$array); //执行命令 print_r($array); ? 2、system函数 ?php $test = "ls /tmp/test"; $last = system($t

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  1、exec函数

  

  $test = "ls /tmp/test";   //ls是linux下的查目录,文件的命令

  exec($test,$array);       //执行命令

  print_r($array);

  ?>

  2、system函数

  

  $test = "ls /tmp/test";

  $last = system($test);

  print "last: $last\n";

  ?>

  3、passthru函数

  

  $test = "ls /tmp/test";

  passthru($test);

  ?>

  4、popen函数

  

  $test = "ls /tmp/test";

  $fp = popen($test,"r");  //popen打一个进程通道

  while (!feof($fp)) {      //从通道里面取得东西

  $out = fgets($fp, 4096);

  echo  $out;         //打印出来

  }

  pclose($fp);

  ?>

  5、proc_open函数

  

  $test = "ls /tmp/test";

  $arrayarray =   array(

  array("pipe","r"),   //标准输入

  array("pipe","w"),   //标准输出内容

  array("pipe","w")    //标准输出错误

  );

  $fp = proc_open($test,$array,$pipes);   //打开一个进程通道

  echo stream_get_contents($pipes[1]);    //为什么是$pipes[1],因为1是输出内容

  proc_close($fp);

  ?>

  6、proc_open函数

  

  $test = "ls /tmp/test";

  $arrayarray =   array(

  array("pipe","r"),   //标准输入

  array("pipe","w"),   //标准输出内容

  array("pipe","w")    //标准输出错误

  );

  $fp = proc_open($test,$array,$pipes);   //打开一个进程通道

  echo stream_get_contents($pipes[1]);    //为什么是$pipes[1],因为1是输出内容

  proc_close($fp);

  ?>

  7、shell_exec函数

  

  $test = "ls /tmp/test";

  $out = shell_exec($test);

  echo $out;

  ?>

php调用Linux系统常用命令

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境