apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: Example

Source Location: /Console_Getargs-1.3.5/examples/example2.php

Class Overview


Dummy class for example.


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 79]
Dummy class for example.

This class returns the number of lines in a given file. It can optionally give you the first X lines, plus "highlight" certain words by surrounding them in '*'. When told to, this class can get very chatty.

Please note that this class is not intended to be overly useful or efficient. It is meant simply to demonstrate the capabilities of Console_Getargs. It may be neccessary to change some paths depending on how you have installed Console_Getargs and the setup of your system.

Run the following commands to see how to use Console_Getargs:

$ php -q example2.php -h $ php -q example2.php $ php -q example2.php -v 1 $ php -q example2.php -v $ php -q example2.php -dv $ php -q example2.php -dvs 10 $ php -q example2.php -vs 10 -f if $ php -q example2.php -vs 10 -hi if $ php -q example2.php -vs 10 -f if file $ php -q example2.php -s 10 ../Getargs.php $ php -q example2.php -s 10 -f if file --parameters=../Getargs.php

Also try creating your own array of arguments and passing it to the example instance on construction. You array should be numerically indexed. Here are a few examples: array('-d', '-vs', '10') array('--debug', '--verbose', '../Getargs.php');



[ Top ]


Class Variables

$debug =

[line 85]

Show debug output.

Type:   boolean


[ Top ]

$file =

[line 90]

The complete path to the file to count lines in.

Type:   string


[ Top ]

$findWords = array()

[line 105]

The words to find and highlight.

Type:   array


[ Top ]

$showLines =

[line 95]

How many lines to show.

Type:   integer


[ Top ]

$verbose =

[line 100]

The level of chattyness.

Type:   integer


[ Top ]



Method Detail

Example (Constructor)   [line 118]

void Example( [array $argArray = NULL])

Constructor.

This will create an instance of the example object. If you pass an array of arguments on construction, that array will be used instead of the default agument list.

  • Access: public

Parameters:

array   $argArray   —  The optional argument list.

[ Top ]

countLines   [line 273]

integer countLines( none 0)

Return the number of lines in the file.
  • Access: public

Parameters:

none   0   — 

[ Top ]

display   [line 226]

void display( none 0)

The method for displaying the results.

This will output atleast the number of lines. Depending on the options passed on the command line, more info may be shown.

  • Access: public

Parameters:

none   0   — 

[ Top ]

find   [line 328]

string find( string $text)

Highlight the requested words.

If the user wants some words highlighted, surround them in '*'.

  • Access: public

Parameters:

string   $text   —  The text to find words in.

[ Top ]

getConfigArray   [line 172]

&array &getConfigArray( none 0)

Return the config array.

The config array is the set of rules for command line arguments. For more details please read the comments in Getargs.php

  • Access: public

Parameters:

none   0   — 

[ Top ]

getFirstXLines   [line 288]

string getFirstXLines( none 0)

Return the requested number of lines.

Depending on the arguments passed on the command line, some words may be surrounded with '*'.

  • Access: public

Parameters:

none   0   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:40:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.