လက်ရှိတည်နေရာ: ပင်မစာမျက်နှာ> ဖန်ရှင်အမျိုးအစားများ> proc_open

proc_open

command ကို execute လုပ်ပြီး input / output အတွက်အသုံးပြုသောဖိုင်ညွှန်ပြမှုကိုဖွင့်ပါ
အမည်:proc_open
အမျိုးအစား:ပရိုဂရမ်ကွပ်မျက်
programming language:php
တစ်ကြောင်းဖြင့်အကျဉ်းချုပ်:command ကို execute လုပ်ပြီး input / output အတွက်အသုံးပြုသောဖိုင်ညွှန်ပြမှုကိုဖွင့်ပါ

function name: proc_open ()

function ကိုဖော်ပြချက် - proc_open () function ကို command ကို exitute လုပ်ပြီး input / output အတွက်အသုံးပြုသောဖိုင်ညွှန်ပြချက်ကိုဖွင့်သည်။

သက်ဆိုင်သောဗားရှင်း: PHP 4> = 4.3.0, PHP 5, PHP 7

Syntax: အရင်းအမြစ် proc_open (string $ cmd, array $ descriptorspec, array & $ cwd [, array $ awd [, array $ awd]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

Parametermer

  • CMD - ကွပ်မျက်ခံရမည့် command သည်ရိုးရှင်းသော command တစ်ခုသို့မဟုတ် command များနှင့် parameters များကိုပါ 0 င်သည်။
  • Descriptorspec: Input / Output အတွက်ဖိုင်ညွှန်ပြထားတဲ့ array ။ Element တစ်ခုစီသည်အောက်ပါသော့ချက်တန်ဖိုးများပါ 0 င်သည့်ခင်းကျင်းမှုတစ်ခုဖြစ်သည်။
    • 0: စံ input ကို (စတီနင်)
    • 1: စံ output (stdout)
    • 2: စံအမှား (Stderr)
  • ပိုက်များ - Input / Output အတွက်ဖိုင်ညွှန်ပြချက်အားလုံးကိုတပ်ဆင်ထားသည်
  • CWD (optional) - command ကိုကွပ်မျက်ခံရမည့်လက်ရှိအလုပ်လုပ်သောလမ်းညွှန်
  • impn (optional ကို): ပတ်ဝန်းကျင် variable တွေကိုသတ်မှတ်ထားတဲ့ array တစ်ခု
  • Other_options (optional) - အပိုဆောင်းရွေးချယ်စရာများပါ 0 င်သည့်အပေါင်းအသင်းဆိုင်ရာခင်းကျင်းမှု။ ထောက်ခံရွေးချယ်စရာများမှာ -
    • Suppress_Error များ - အမှားအယွင်းများကိုပုံမှန်အမှားများသို့ပေးပို့ခြင်းကိုပိတ်ထားသည်။ ပုံမှန်ကမှားတယ်

Return Value: အောင်မြင်သောအခါအရင်းအမြစ်အမျိုးအစားအမှတ်အသားကိုပြန်လည်သတ်မှတ်ပြီးပျက်ကွက်သည့်အခါမှားယွင်းသောအယူမှားပြန်ပို့သည်။

နမူနာကုဒ်:

 // 执行一个简单的命令并读取输出$descriptorspec = array( 0 => array("pipe", "r"), // 标准输入1 => array("pipe", "w"), // 标准输出2 => array("pipe", "w") // 标准错误); $process = proc_open('ls -l', $descriptorspec, $pipes); if (is_resource($process)) { // 读取输出echo stream_get_contents($pipes[1]); // 关闭文件指针fclose($pipes[0]); fclose($pipes[1]); fclose($pipes[2]); // 等待进程结束,并获取返回值$return_value = proc_close($process); }

ဤဥပမာတွင်ကျွန်ုပ်တို့သည် Proc_open () ကို အသုံးပြု. ရိုးရိုးရှင်းရှင်း command တစ်ခုပြုလုပ်ရန်နှင့် command ၏ output ကိုဖတ်ရန်ဖိုင်ညွှန်ပြချက်ကိုသုံးပါ။ သင့်လျော်သော Descriptorspec Array ကိုသတ်မှတ်ခြင်းအားဖြင့်ကျွန်ုပ်တို့သည် Input / Output အတွက်ဖိုင်ညွှန်းကိန်းအမျိုးအစားကိုသတ်မှတ်နိုင်သည်။ ဤဥပမာတွင်ကျွန်ုပ်တို့သည်ပုံမှန်ပိုက်လိုင်းနှစ်ခုနှင့်စံသတ်မှတ်ထားသော output နှင့်စံအမှားအယွင်းတစ်ခုသို့စံသတ်မှတ်ချက်တစ်ခုနှင့်စံသတ်မှတ်ချက်ကိုတစ်ပြိုင်နက်တည်း redirect ။ ထို့နောက်ကျွန်ုပ်တို့သည် stream_get_contontents () function ကို သုံး. ပုံမှန် output pipeline မှ command ၏ output ကိုဖတ်ရန်။ နောက်ဆုံးအနေဖြင့်ကျွန်ုပ်တို့သည်ဖိုင်ညွှန်ကြားချက်များအားလုံးကိုပိတ်ပြီးလုပ်ငန်းစဉ်ကိုအဆုံးသတ်ရန်နှင့်ပြန်လာတန်ဖိုးကိုရရှိရန်စောင့်ဆိုင်းရန် proc_close () ကိုအသုံးပြုသည်။

သက်ဆိုင်သောဖင်ခှ်ရှင်းများ
  • Shell command တွင်အသုံးပြုနိုင်သည့် parameters တွေကို parameters တွေကို transcode escapeshellarg

    escapeshellarg

    Shellcommandတွင်အသုံ
  • လက်ရှိလုပ်ငန်းစဉ်၏ ဦး စားပေးပြောင်းလဲမှု proc_nice

    proc_nice

    လက်ရှိလုပ်ငန်းစဉ်၏ဦး
  • ပြင်ပပရိုဂရမ်များ Execute လုပ်ခြင်းနှင့် output ကိုပြသခြင်း system

    system

    ပြင်ပပရိုဂရမ်များExe
  • ပြင်ပပရိုဂရမ်တစ်ခုကိုလုပ်ဆောင်ပါ exec

    exec

    ပြင်ပပရိုဂရမ်တစ်ခုကိ
  • ပြင်ပပရိုဂရမ်များကို Execute လုပ်ပြီးမူလထုတ်လုပ်မှုကိုပြပါ passthru

    passthru

    ပြင်ပပရိုဂရမ်များကို
  • shell ကို Metacharacter Elae escapeshellcmd

    escapeshellcmd

    shellကိုMetacharacte
  • command ကို execute လုပ်ပြီး input / output အတွက်အသုံးပြုသောဖိုင်ညွှန်ပြမှုကိုဖွင့်ပါ proc_open

    proc_open

    commandကိုexecuteလုပ
  • proc_open () function ကိုဖွင့်လှစ်သည့်လုပ်ငန်းစဉ်များအကြောင်းသတင်းအချက်အလက်များကိုရယူပါ proc_get_status

    proc_get_status

    proc_open()functionက
လူကြိုက်များသော ဆောင်းပါးများ