Инструменты пользователя

Инструменты сайта

Боковая панель



PHP CLI в командной строке(command line)

  • Пример.
    php -r 'print_r(get_defined_constants());'
  • Пример. PHP stdin Command Line Input From User
    // show them a message to enter their name
    echo "Tell us your name: " . PHP_EOL;
    // the script will wait here until the user has entered something and hit ENTER
    $name = read_stdin();
    // This will display the thank you message including their name they entered.
    echo "Thank you $name. Welcome to my site" . PHP_EOL;
    // our function to read from the command line
    function read_stdin()
            $fr=fopen("php://stdin","r");   // open our file pointer to read from stdin
            $input = fgets($fr,128);        // read a maximum of 128 characters
            $input = rtrim($input);         // trim any trailing spaces.
            fclose ($fr);                   // close the file handle
            return $input;                  // return the text entered
Kwork.ru - услуги фрилансеров от 500 руб.
php_cli_v_komandnoj_stroke_command_line.txt · Последнее изменение: 2020/06/13 13:46 (внешнее изменение)