简体   繁体   中英

Php-cli less resoult

I start coding php-cli script for manipulation with hosts and VirtualHost files in linux.

https://github.com/ErgallM/deep all program

In https://github.com/ErgallM/deep/blob/master/library/Host.php#L34 printing hosts element.

How to less php output?

You can do fgets() on STDIN file after you output like 30 lines. This will cause user to wait.

A quick hack would be to prefix your code with....

 <?php

   $reentry='reenteredxx123';
   if ($argv[1]!=$reentry) {
      $script=aray_shift($argv);
      $clean=array_map('escapeshellarg',$argv);
      $cmd="php $script $reentry" . implode(' ',$clean) . ' | less';
      system($cmd);
      exit;
   } else {
      unset($argv[1]);
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM