DATA CONVERSION
int intval ( mixed $var )
Returns an integer value for the variable. Returns null if a string
cannot be interpreted as a number.
double floatval ( mixed $var )
Alias for doubleval().
double doubleval ( mixed $var )
Returns a double value for the variable. Returns null if a string
cannot be interpreted as a number.
mixed unpack ( string $str, int $offset, int $length [, boolean $float ] )
This function is used to extract data packed into the string (binary byte
array)
$str. Values are assumed to be packed in big-endian order beginning
at the provided
$offset. The size of the parameter is defined by
$length.
The optional boolean
$float is FALSE by default and if set to TRUE
indicates that data is stored in IEEE 754 floating point format.
With
$float set to FALSE this returns an INTEGER whose value is stored
starting at
$offset in
$str for
$length bytes. This will retrieve a byte
value ($length = 1), a short value ($length = 2) or an int ($length = 4).
64-bit values cannot be directly retrieved as there is no 64-bit PHP
integer variable type. Values less than 4 bytes in length are unsigned.
With
$float set to TRUE this returns a DOUBLE whose value is stored in
IEEE 754 format at
$offset in
$str for $length bytes. This retrieves a
float value (length = 4) or a double value (length = 8).
A NULL value is returned for any invalid combination of
$length and
$float. A NULL value is also returned for any attempted out of bounds
string (array) reference.
mixed endian ( mixed $var )
Reverses the endian order of a numeric value. This returns a variable of
the same type and affects only numeric values.
string urlencode ( mixed $var )
Encodes any non-alpha characters not in the set [-_a-zA-Z] using %##
encoding. Plus symbols ('+') replace space characters.
string urldecode ( mixed $var )
Decodes any %## encoding in the given string. Plus symbols '+' are
decoded to a space character.
string base64_decode( mixed $var )
Decodes Base64 encoded string.
string base64_encode( mixed $var )
Encodes string in Base64.
DATE AND TIME
int time ( void )
Returns the current time in seconds since midnight Jan, 1 1970 UTC.
Same as
getutc() .
int getutc ( void )
Returns the current time in seconds since midnight Jan, 1 1970 UTC.
Same as
time() .
string date ( string $format, [ int time ] )
Returns a string formatted according to the given format using the
specified timestamp or the current time if no timestamp is provided.
If omitted the timestamp would be the value of
time() . A partial set
of PHP-like formatting specifiers are supported. Either UTC or Local
Time may be represented depending on the occurrence of 'U' or 'L' in
the format string. Local Time is the default. Daylight Saving Time (DST)
is applied if appropriate for the local timezone.
Day
d Day of the month, 2 digits with leading zeros (01-31)
D A textual representation of the day, 3 letters (Mon-Sun)
j Day of the month without leading zeros (1-31)
Month
m Numeric representation of the month, with leading zeros (01-12)
M A short textual representation of a month, 3letters (Jan-Dec)
n Numeric representation of a month, without leading zeros (1-12)
Year
Y A full numeric representation of a year, 4 digits
y A two digit representation of a year
Time
a Lowercase Ante meridiem or Post meridiem (am or pm)
A Uppercase Ante meridiem or Post meridiem (AM or PM)
g 12-hour format of an hour without leading zeros (1-12)
G 24-hour format of an hour without leading zeros (0-23)
h 12-hour format of an hour with leading zeros (01-12)
H 24-hour format of an hour with leading zeros (00-23)
i Minutes with leading zeros (00-59)
s Seconds with leading zeros (00-59)
Timezone
U Represent Universal Coordinated Time (UTC)
L Represent Local Time (default)
e Timezone identifier, same as 'T' (EST or UTC)
T Timezone abbreviation (EST or UTC)
string gmtime ( [ int time ] )
Formats a time value as a string. If the parameter is omitted the current
time is formatted. The time value is in seconds since midnight
Jan, 1 1970 UTC. The resulting string is formatted, for example, as:
"Thu, 19 Nov 2015 13:13:12 EST".
This is the same as:
date("D, d M Y H:i:s T").
FILE OPERATIONS
int filesize(string $filename)
Returns the length of the file in bytes.
int filemtime ( string $filename )
This function returns the timestamp when the content of the file was last
changed. This is the number of seconds since midnight Jan 1, 1970 in UTC.
bool file_exists(string $filename)
Returns TRUE if the file/directory referenced by the supplied
specification exists and FALSE otherwise.
bool is_file(string $filename)
Returns TRUE if the file referenced by the supplied specification exists
and is not a folder.
bool unlink(string $filename)
Deletes the specified file. Returns TRUE if successful.
int fopen(string $filename, string $flags)
Opens a file for reading, writing, etc. The $flags parameter defines
the mode of access following the Standard C Liobrary conventions. For
reading a file would typically be opened using the flag string "rb".
For writing the string "wb" would be appropriate.
int fread(int $handle [, int $length] )
Returns a string containing up to $length bytes from the file. If
$length is omitted the entire content of the file will be read.
int fread(string $filename)
Returns a string containing the entire content of the file defined by
the supplied specification.
int fwrite(int $handle, $string [, int $length] )
Writes the content of $string to the associated file. If specified, a
maximum of $length bytes will be written. Returns the number of bytes
written or FALSE on error.
int fwrite(string $filename, $string)
Creates the file defined by the supplied specification containing
the content of $string.
bool feof(int $handle)
Returns TRUE if the file has reached the end-of-file.
int fclose(int $handle)
Closes the file resource. It is good practice to close files that have
been opened for reading or writing. There are only a limited number of
available file handles.
String getcwd( )
Returns the current working directory.
bool chdir(string $directory)
Change working directory. Returns FALSE if the new specification does
not result in an existing folder.
array scandir(string $directory)
Return an array of files and folders from the referenced directory.
bool is_dir(string $directory)
Returns TRUE if the directory referenced by the supplied specification
exists and is not a file.
bool mkdir(string $directory)
Creates the specified folder if it does not exist. Returns TRUE if
successful.
bool rmdir(string $directory)
Removes the specified folder if it does not exist. Returns TRUE if
successful.
string file_crc ( string $filename )
Returns a string of length 8 containing the hexadecimal CRC32 checksum
calculated for the contents of the file.
string file_md4 ( string $filename )
Returns a string of length 32 containing the hexadecimal MD4 message
digest calculated for the contents of the file.
string file_md5 ( string $filename )
Returns a string of length 32 containing the hexadecimal MD5 message
digest calculated for the contents of the file.
string file_sha1 ( string $filename )
Returns a string of length 40 containing the hexadecimal SHA1 message
digest calculated for the contents of the file.
string file_sha2 ( string $filename )
Returns a string of length 64 containing the hexadecimal SHA256 message
digest calculated for the contents of the file.
JSON SUPPORT
Support for JSON (JavaScript Object Notation -
json.org ) is provided.
JSON is used in many different ways. It is also a good means of preserving
a PHP array structure in file storage and in thereby implementing a rudimentary
database.
array json_decode( string $json )
Returns an array structure for the JSON object supplied in JSON string
representation.
string json_encode( array $json )
Returns the JSON string representation of an array object.
array json_load( string $filename )
Returns an array structure representing the JSON object stored in the
referenced file. The file contains the string representation of the
JSON object.
boolean json_save( string $filename, array $json )
Stores an array structure representing a JSON object in the referenced
file. The file will contain the string representation of the JSON object.
Returns TRUE when the write is successful.
LANGUAGE SUPPORT
There are functions provided that ascertain the status of a variable.
bool is_null( mixed $var )
Tests if a variable is NULL. Returns
True or
False .
bool is_bool( mixed $var )
Tests if a variable is Boolean. Returns
True or
False .
bool is_int ( mixed $var )
Tests if a variable is an Integer. Returns
True or
False .
bool is_double ( mixed $var )
Tests if a variable is a Double. We store all floating point values
as Double. Returns
True or
False .
bool is_string ( mixed $var )
Tests if a variable is a string. Returns
True or
False .
bool is_array ( mixed $var )
Tests if a variable is an array. Returns
True or
False .
bool isset ( mixed $var )
Returns TRUE is the variable has been assigned a value.
bool empty ( mixed $var )
Determine whether a variable is considered to be empty. A variable is
considered empty if it does not exist or if its value equals FALSE. This
is equivalent to:
isset($var) || $var == false.
REGISTRY ACCESS
The Registry stores name-value data typically for configuration. A script
may need access to defined settings or be able to preserve settings of its
own. These function access the JANOS Registry system.
string getRegistryString(string $key [, string $default])
Gets the content of the supplied Registry key. Note that this returns an
empty string if the key has not been defined. Note also that an empty
string is considered to be a FALSE boolean so the returned string can be
used in a conditional statement.
bool getRegistryBoolean(string $key [, boolean $dflt])
Returns the boolean equivalent of the Registry key value.
bool setRegistryString(string $key, string $value)
Sets the content of the supplied Registry key. The key is deleted if
the supplied value is an empty string.
string[] getRegistryList(string $node [, $children = False])
Returns and array of fully qualified keys for entries (children = False)
or child nodes (children = True) within the specified node.
SYSTEM FUNCTIONS
void syslog ( string $message )
Enters the message in the system log jniorsys.log file.
void flush ( void )
Flushes buffers and attempts to send any output generated to the browser
or console.
void sleep ( int $milliseconds )
Flushes buffers and sleeps the process for the defined number of milli-
seconds. If a script must wait for an external event it is important to
allow the processor to perform other tasks.
void yield ( void )
Yields the process. This should be used by extremely lengthy procedures
to reduce the load on the processor and avoid watchdog timeouts.
REGULAR EXPRESSIONS
Regular Expressions (REGEX) define string search patterns. JANOS scripting
can utilize these.
int ereg ( string $pattern, string $substring [, array $regs] )
Returns the position in $substring of a match with $pattern. Returns
FALSE otherwise. If $regs is supplied on a match it is set as an array
whose first element is the matched string.
int eregi ( string $pattern, string $substring [, array $regs] )
Returns the position in $substring of a match with $pattern. Returns
FALSE otherwise. If $regs is supplied on a match it is set as an array
whose first element is the matched string. Case-independent comparisons
are performed.
array split( string $pattern, string $substring [, int $limit] )
Returns an array of string tokens from $substring using matches to
$pattern as the separators. If $limit is provided the returned array
will be limited to that number of entries where the last entry will
contain the balance of the original string.
array spliti ( string $pattern, string $substring [, int $limit] )
Returns an array of string tokens from $substring using matches to
$pattern as the separators. If $limit is provided the returned array
will be limited to that number of entries where the last entry will
contain the balance of the original string. Comparisons are
case-independent.
string ereg_replace ( string $pattern, string $replacement, string $substring )
Replaces all matches to $pattern in $substring with the string
$replacement. Returns FALSE on error. Returns the original string
if no matches are found.
string eregi_replace ( string $pattern, string $replacement, string $substring )
Replaces all matches to $pattern in $substring with the string
$replacement. Returns FALSE on error. Returns the original string
if no matches are found. Comparisons are case-independent.
[/flash/manpages/scripting.hlp:1222]