public function substring( $beginIndex, $endIndex = null ) {
		if ( $beginIndex < 0 ) {
			throw new GStringIndexOutOfBoundsException( $beginIndex );
		} else if ( $beginIndex == $this->length() ) {
			return new GString( "" );
		}
		if ( $endIndex === null ) {
			$length = $this->length() - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		} else {
			if ( $endIndex > $this->length() ) {
				throw new GStringIndexOutOfBoundsException( $endIndex );
			}
			$length = $endIndex - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 && $endIndex == $this->length() ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		}
	}
public function substring( $beginIndex, $endIndex = null ) {
		if ( $beginIndex < 0 ) {
			throw new GStringIndexOutOfBoundsException( $beginIndex );
		} else if ( $beginIndex == $this->length() ) {
			return new GString( "" );
		}
		if ( $endIndex === null ) {
			$length = $this->length() - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		} else {
			if ( $endIndex > $this->length() ) {
				throw new GStringIndexOutOfBoundsException( $endIndex );
			}
			$length = $endIndex - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 && $endIndex == $this->length() ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		}
	}
public function substring ( $ beginIndex , $ endIndex = null ) { if ( $ beginIndex < 0 ) { throw new GStringIndexOutOfBoundsException ( $ beginIndex ) ; } else if ( $ beginIndex == $ this -> length ( ) ) { return new GString ( "" ) ; } if ( $ endIndex === null ) { $ length = $ this -> length ( ) - $ beginIndex ; if ( $ length < 0 ) { throw new GStringIndexOutOfBoundsException ( $ length ) ; } if ( $ beginIndex == 0 ) { return $ this ; } else { return new GString ( $ this -> value , $ beginIndex , $ length ) ; } } else { if ( $ endIndex > $ this -> length ( ) ) { throw new GStringIndexOutOfBoundsException ( $ endIndex ) ; } $ length = $ endIndex - $ beginIndex ; if ( $ length < 0 ) { throw new GStringIndexOutOfBoundsException ( $ length ) ; } if ( $ beginIndex == 0 && $ endIndex == $ this -> length ( ) ) { return $ this ; } else { return new GString ( $ this -> value , $ beginIndex , $ length ) ; } } }
Returns a new GString that is a substring of this string.

@access public

@param int $beginIndex The beginning index, inclusive
@param int $endIndex The ending index, exclusive

@return \String the specified substring.
@throws StringIndexOutOfBoundsException
Returns a new GString that is a substring of this string .