暂无描述

example.php 1006B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $loader = require_once __DIR__ . '/vendor/autoload.php';
  3. $consoleColor = new JakubOnderka\PhpConsoleColor\ConsoleColor();
  4. echo "Colors are supported: " . ($consoleColor->isSupported() ? 'Yes' : 'No') . "\n";
  5. echo "256 colors are supported: " . ($consoleColor->are256ColorsSupported() ? 'Yes' : 'No') . "\n\n";
  6. if ($consoleColor->isSupported()) {
  7. foreach ($consoleColor->getPossibleStyles() as $style) {
  8. echo $consoleColor->apply($style, $style) . "\n";
  9. }
  10. }
  11. echo "\n";
  12. if ($consoleColor->are256ColorsSupported()) {
  13. echo "Foreground colors:\n";
  14. for ($i = 1; $i <= 255; $i++) {
  15. echo $consoleColor->apply("color_$i", str_pad($i, 6, ' ', STR_PAD_BOTH));
  16. if ($i % 15 === 0) {
  17. echo "\n";
  18. }
  19. }
  20. echo "\nBackground colors:\n";
  21. for ($i = 1; $i <= 255; $i++) {
  22. echo $consoleColor->apply("bg_color_$i", str_pad($i, 6, ' ', STR_PAD_BOTH));
  23. if ($i % 15 === 0) {
  24. echo "\n";
  25. }
  26. }
  27. echo "\n";
  28. }