PHP Classes

File: test_php5.php

Recommend this page to a friend!
  Classes of Steffen Stollfuß   cmd class   test_php5.php   Download  
File: test_php5.php
Role: Example script
Content type: text/plain
Description: cmd_class_php5.php test and example file
Class: cmd class
Access input/output data from command line scripts
Author: By
Last change: - fixed a wrong string for variable
Date: 9 years ago
Size: 2,204 bytes
 

Contents

Class file image Download
<?php
require_once './cmd_class_php5.inc';
$bytes = 0;
$str = "CommandLind class test string";
$strings = array("Line 1", "Line 2", "Line 3");
/**
 * Write the strings to STDOUT
 */
$bytes = CommandLine::writeline("STDOUT resource tests ...");
$bytes = CommandLine::writeline("Bytes written: ". $bytes);
$bytes = CommandLine::write($str.PHP_EOL);
$bytes = CommandLine::writeline("Bytes written: ". $bytes);
$bytes = CommandLine::writeline($str);
$bytes = CommandLine::writeline("Bytes written: ". $bytes);
$bytes = CommandLine::writelines($strings);
$bytes = CommandLine::writeline("Bytes written: ". $bytes);
$bytes = CommandLine::writeline("Another commandline test string");
$bytes = CommandLine::writeline("Bytes written: ". $bytes);


/**
 * Write the strings to STDERR
 */
$bytes = CommandLine::writeline("STDERR resource tests ...");
CommandLine::write($str, STDERR);
CommandLine::write(PHP_EOL, STDERR);
CommandLine::writeline($str, STDERR);
CommandLine::writelines($strings,STDERR);
CommandLine::writeline("Another commandline test string");

/**
 * Lazy scripter tests ;)
 */
use CommandLine as CMD;
CMD::writeline("I'm a lazy scripter so I make");
CMD::writeline("use CommandLine as CMD;");

/**
 * CommandLine reading tests
 */
$number = null;
CMD::write("Type a floating point number: ");
CMD::readFloat($number);
CMD::writeline("Floating point number: ". $number);
CMD::writeline("Type of number is: ". gettype($number));

$number = null;
CMD::write("Type an integer number: ");
CMD::readInt($number);
CMD::writeline("Integer number: ". $number);
CMD::writeline("Type of number is: ". gettype($number));

$line = null;
CMD::write("Type a string (enter): ");
CMD::readLine($line);
CMD::writeline("String: ". $line);
CMD::writeline("Type of \$line is: ". gettype($line));

$char = null;
CMD::write("Type a ascii line (enter): ");
CMD::readAsciiToChar($char);
CMD::writeline("Char: ". $char);
CMD::writeline("Type of \$char is: ". gettype($char));

$octal = null;
CMD::write("Type aa octal number (enter): ");
CMD::readOctal($octal);
CMD::writeline("Char: ". $octal);
CMD::writeline("Type of \$octal is: ". gettype($octal));