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

Class: JavascriptString

Source Location: /JavascriptString.class.php

Class Overview

String
   |
   --JavascriptString

Extension to the String class to define similar methods like in javascript.


Author(s):

  • Benjamin Hofmann

Version:

  • 1.1.0

Copyright:

  • Benjamin Hofmann

Methods


Inherited Constants

Inherited Variables

Inherited Methods

Class: String

String::__construct()
With this method a new string is created.
String::add()
Adds the given string to the existing string.
String::addMore()
With this you can add an array of strings.
String::callFunction()
Calls the given string function.
String::copy()
Creates a new String object from the existing one.
String::edit()
Calls the given string function.
String::get()
Returns the string.
String::insert()
To insert a string into an existing one use this method.
String::insertMore()
To insert an array of string into an existing one use this method.
String::reset()
Resets the existent string.
String::set()
Sets a string for further editing or return of the string.
String::show()
Shows the string.
String::__call()
This magic method will be used if the used method does not actually exist.
String::__toString()
This magic method will be used if a script tries to cast this object into a normal string.

Class Details

[line 31]
Extension to the String class to define similar methods like in javascript.

Extension to the String class to define similar methods like in javascript.




Tags:

author:  Benjamin Hofmann
version:  1.1.0
copyright:  Benjamin Hofmann
link:  http://www.ajaveeb.de/entwicklungen/php-klasse-fuer-strings-306/
since:  2009-04-15


[ Top ]


Class Methods


method charAt [line 45]

mixed charAt( int $position)

Returns the character at the given position.

Returns the character at the given position. If there is no character false will be returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->charAt(5);




Tags:

access:  public


Parameters:

int   $position  

[ Top ]

method charCodeAt [line 68]

mixed charCodeAt( int $position)

Returns the ASCII-Code for the character at the given position.

Returns the ASCII-Code for the character at the given position. If there is no character false will be returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->charCodeAt(5);




Tags:

access:  public


Parameters:

int   $position  

[ Top ]

method concat [line 94]

JavascriptString concat( string $string)

Wrapper for String->add().

Wrapper for String->add(). Just defined because it is available in javascript. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->concat('added string');




Tags:

access:  public


Parameters:

string   $string  

[ Top ]

method fromCharCode [line 114]

JavascriptString fromCharCode( $charCodes)

Takes an integer array, creates for each value the character and adds it to the string.

Takes an integer array, creates for each value the character and adds it to the string. Important: The string is completely overwritten by this method! Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->fromCharCode(array(656667));




Tags:

access:  public


Parameters:

array   $charCodes  

[ Top ]

method indexOf [line 144]

mixed indexOf( string $search)

Looks for the first occurence of the given string and returns the position of the first character.

Looks for the first occurence of the given string and returns the position of the first character. If the string is not found false will be returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->indexOf('search');




Tags:

access:  public


Parameters:

string   $search  

[ Top ]

method lastIndexOf [line 161]

mixed lastIndexOf( string $search)

Looks for the last occurence of the given string and returns the position of the first character.

Looks for the last occurence of the given string and returns the position of the first character. If the string is not found false will be returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->lastIndexOf('search');




Tags:

access:  public


Parameters:

string   $search  

[ Top ]

method length [line 175]

int length( )

Counts all characters of the string and returns the sum of them.

Counts all characters of the string and returns the sum of them. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->length();




Tags:

access:  public


[ Top ]

method match [line 190]

array match( string $regExp)

This is a wrapper for preg_match_all() and returns every found match for the given regular expression.

This is a wrapper for preg_match_all() and returns every found match for the given regular expression. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->match('/search/');




Tags:

access:  public


Parameters:

string   $regExp  

[ Top ]

method replace [line 208]

JavascriptString replace( string $regExp, string $string)

This is a wrapper for preg_replace and replaces every occurence of the given regular expression with the given replacement.

This is a wrapper for preg_replace and replaces every occurence of the given regular expression with the given replacement. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->replace('/search/''replace');




Tags:

access:  public


Parameters:

string   $regExp  
string   $string  

[ Top ]

method search [line 228]

mixed search( string $regExp)

This method searches for the given regular expression and returns the position of the first character of it, when found.

This method searches for the given regular expression and returns the position of the first character of it, when found. If nothing is found false will be returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->search('/search/');




Tags:

access:  public


Parameters:

string   $regExp  

[ Top ]

method slice [line 251]

string slice( int $start, [int $end = null])

This is a wrapper for JavascriptString->substring().

This is a wrapper for JavascriptString->substring(). Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->slice(1020);




Tags:

access:  public


Parameters:

int   $start  
int   $end  

[ Top ]

method split [line 266]

array split( mixed $seperator)

Splits the existent string at the given seperator and returns the parts as array.

Splits the existent string at the given seperator and returns the parts as array. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->split(' ');




Tags:

access:  public


Parameters:

mixed   $seperator  

[ Top ]

method substr [line 284]

string substr( int $start, [int $length = null])

Returns the string from the given starting position with the given length.

Returns the string from the given starting position with the given length. If no end position is given everything from the starting position is returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->substr(1020);




Tags:

access:  public


Parameters:

int   $start  
int   $length  

[ Top ]

method substring [line 310]

string substring( int $start, [int $end = null])

Returns the string from the given starting position to the given end position.

Returns the string from the given starting position to the given end position. If no end position is given everything from the starting position is returned. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->substring(1020);




Tags:

access:  public


Parameters:

int   $start  
int   $end  

[ Top ]

method toLowerCase [line 333]

JavascriptString toLowerCase( )

Transforms every character in the existent string to his lower version.

Transforms every character in the existent string to his lower version. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->toLowerCase();




Tags:

access:  public


[ Top ]

method toUpperCase [line 350]

JavascriptString toUpperCase( )

Transforms every character in the existent string to his upper version.

Transforms every character in the existent string to his upper version. Usage:

  1. $string new String('This is the new string.');
  2.  $string $string->toUpperCase();




Tags:

access:  public


[ Top ]


Documentation generated on Sun, 05 Jul 2009 15:24:31 +0200 by phpDocumentor 1.4.1