Scanner

php\util\Scanner

implements: Iterator

A simple text scanner which can parse primitive types and strings using regular expressions.

Class Scanner

Methods


__construct($source, $charset = null)

throws php\lang\IllegalArgumentException if $charset is invalid

Parameters:
  • $sourcestring, php\io\Stream
  • $charsetstring, null - e.g.: UTF-8, windows-1251, etc., only for Stream objects
hasNext($pattern = null)
Parameters:
Returns:

bool

next($pattern = null)
Parameters:
Returns:

string, null null if doesn’t has the next pattern

nextLine()
Returns:string, null null if doesn’t has the next line
hasNextLine()
Returns:bool
nextInt($radix = null)
Parameters:
  • $radixnull, int - if null then uses the default radix
Returns:

int, null null if doesn’t has the next int

hasNextInt($radix = null)
Parameters:
  • $radixnull, int - if null then uses the default radix
Returns:

bool

nextDouble()
Returns:float, null null if does not has the next double
hasNextDouble()
Returns:bool
skip($pattern)
Parameters:
Returns:

bool true on success, false on fail

useDelimiter($delimiter)
Parameters:
Returns:

php\util\Scanner

useLocale($locale)
Parameters:
Returns:

php\util\Scanner

useRadix($value)
Parameters:
  • $valueint
Returns:

php\util\Scanner

getIOException()

Get the last io exception (if does not occur then returns null)

Returns:php\io\IOException, null
reset()
current()

Uses the result of the last called next() method

Returns:string
key()
Returns:int
valid()
Returns:bool
rewind()
__clone()

private