当前位置: 首页>>代码示例>>PHP>>正文


PHP Cli::writeError方法代码示例

本文整理汇总了PHP中Cli::writeError方法的典型用法代码示例。如果您正苦于以下问题:PHP Cli::writeError方法的具体用法?PHP Cli::writeError怎么用?PHP Cli::writeError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cli的用法示例。


在下文中一共展示了Cli::writeError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUploadFormData

 /**
  * Puts together the POST body when uploading files
  *
  * @param array  $postData
  * @param array  $files An array of files like `[string $fileName => string|resource|array $file]`.
  *                      In case $file is an array it provides additional control on file name and contents type.
  *                      Available keys are `path`, `fileContents`, `fileName` and `contentType`. One of `path` or
  *                      `fileContents` is required.
  *                      If `path` is set then `fileName` and `contentType` are optional.
  *                      If `fileContents` is set then `fileName` and `contentType` are required.
  *
  *                      examples:
  *                      <ul>
  *                      <li>['file1' => ['path' => '/tmp/file.php']]</li>
  *                      <li>['file1' => ['path' => '/tmp/file.php'], 'file2' => ['path' => '/tmp/file2.png']]</li>
  *                      <li>['file1' => ['fileContents' => '<?php echo 1;', 'fileName' => 'o.png', 'contentType' => 'image/png']]</li>
  *                      </ul>
  * @param string $formBoundary
  *
  * @return string
  * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
  * @since  0-dev
  */
 protected static function getUploadFormData($postData = [], $files = [], $formBoundary = '__FORM_BOUNDARY__')
 {
     $postData = (array) $postData;
     $formBoundary = preg_replace('/\\W/', '', $formBoundary);
     $payload = [];
     foreach ($postData as $paramName => $value) {
         $payload[] = '--' . $formBoundary;
         $payload[] = 'Content-Disposition: form-data; name="' . $paramName . '"';
         $payload[] = '';
         $payload[] = $value;
     }
     /** @var resource|string|array $file */
     foreach ($files as $paramName => $file) {
         $fileData = self::getFileData($file);
         if (isset($fileData['error'])) {
             Cli::writeError("Something went wrong with file {$paramName} (error: {$fileData['error']}), skipping...");
             continue;
         }
         $payload[] = '--' . $formBoundary;
         $payload[] = 'Content-Disposition: form-data; name="' . $paramName . '"; filename="' . $fileData['fileName'] . '"';
         $payload[] = "Content-Type: {$fileData['contentType']}";
         $payload[] = '';
         $payload[] = $fileData['fileContents'];
         $payload[] = '';
     }
     $payload[] = '--' . $formBoundary;
     $payload[] = '';
     return implode(CRLF, $payload);
 }
开发者ID:wordfence,项目名称:exkit,代码行数:52,代码来源:Request.php

示例2: exitWithFailedRequest

 /**
  * @param string $msg A message to display before exiting
  *
  * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
  * @since  0-dev
  */
 public static function exitWithFailedRequest($msg = '')
 {
     if ($msg) {
         Cli::writeError($msg);
     }
     self::exitWith(self::EXIT_CODE_VALID_REQUEST_FAILED);
 }
开发者ID:wordfence,项目名称:exkit,代码行数:13,代码来源:ExitCodes.php


注:本文中的Cli::writeError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。