Login   Register  
PHP Classes
elePHPant
Icontem

File: console_example1.phpc

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alex Mavrin  >  easy_console  >  console_example1.phpc  >  Download  
File: console_example1.phpc
Role: Example script
Content type: text/plain
Description: First example
Class: easy_console
Process and execute comands from the command line
Author: By
Last change:
Date: 2008-10-10 07:32
Size: 2,001 bytes
 

Contents

Class file image Download
<?php

/**PreInit**************************************************************/
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);
/**PreInit**************************************************************/

require_once ('include/easy_console.php');

/*
*  Lets use static class to perform simple math example...
*/
class Some_User_Class{

      
/*!variable with the same name as mathod treats as description*/
      
public static $plus "Basic sum - Adds [a] to [b] / or [a] ++ (if 1 argument posted)";
      public static function 
plus($arg){
             
/*Using easy_console to chek parameters*/
             
if (easy_console::chek_arg($arg12)) return;

             if (
count($arg) == 2){
               echo 
$arg[1]."++ = ".$arg[1]++;
             }else{
               echo 
"!!!!!!!!!!!\n";
               echo 
$arg[1]." + ".$arg[2]." = ".($arg[1] + $arg[2]);
             }
             echo 
"\n";
             }

      
/*if no description added - (no info) will be shown" /*
      /*No parameters getting, no cheking*/
      
public function dir(){
             
$dir    '.';
             
$files1 scandir($dir);

             
print_r($files1);
      }
      
      public static 
$quit "";
      public function 
quit($a){
            
easy_console::quit();
     }

      
/*Using static private variable...*/
      
static $name "Unknown";
      
/*only public methods are commands*/
      
private function Change_Name($a){
              
Some_User_Class::$name $a;
      }


      public static 
$chn "Show or Change name (Takes 0 or 2 arguments)";
      public function 
chn($arg){
             if (
easy_console::chek_arg($arg01)) return;
             if (
count($arg) == 2){
               
Some_User_Class::Change_Name($arg[1]);
             } else {
               echo (
Some_User_Class::$name)."\n";
             }

      }

}

easy_console::StartCommandLoop('Some_User_Class');
system('PAUSE');
?>