uPHP Reference

uPHP functions have an identical syntax to PHP functions in most cases. Below is a list of all the functions that have been implemented.

See the following topics for more information:

Basic uPHP Syntax

uPHP Special Variables

Click on the function name for further details:


adc_read channel number read onboard ADC channel
array values array object create an array with values
array_key array,index value return key for an array index
array_keys array array return keys for an array
base64_decode strong string returns base64-decoded version of string
base64_encode strong string returns base64-encoded version of string
call_user_func string function_name, optional parameters mixed result calls a user defined function with optional parameters
charat string,index number (ascii code) return ASCII code for character in string at index
chdir string number  
chr number String (1 character) return character for number
cos number or float float return cosine of number
debug string none print to debug output
debugout number   Enabled (1) or disable (0) output to the standard output
die none none kill script
disk_free_space int [volume] number get free space on SD
disk_total_space int [volume] number get total space on SD
error_reporting int debug_level none sets the debug output level
exec string filename, number msinterval   run a script
exec_action mixed action   triggers a manually executable action by id or action name
explode string delimiter,string value array turn a string into an array
f485open int baud, int parity int handle Opens the RS-485 port as a stream. The handle can be used with all file functions. Ensure modbus polling is disabled beforehand.
fclose number handle   Closes a file, stream or socket with the passed handle
feof number handle number Returns 0 if no more data is available, or 1 if there is data
fgets number handle, optional number bytes string or -1 for error returns a single line from the file or stream, optionally upto the number of bytes specified
file_exists string filename number Returns 1 if the file exists
filesize number handle number for files returns the number of bytes in file, for stream returns the number of bytes pending
findfirst string pattern, number flags array Start searching the current folder for files matching the pattern and with specified flags. Returns an array with the first matching info
findnext   array Return next matching file information as array
firmwareupdate     initiates a firmware update sequence and reboots the device
floatval Mixed value number returns the floating point value of the number or string
flush     Flushes current output to the browser
fopen string filename, string status Number handle Opens a file for reading or writing, returns the handle for future operations
fread number handle, number bytes string returns number bytes from the stream
freemem   number Returns bytes free
freestack   number Returns current stack bytes free
fseek number handle, number position, number position_type   Locate file pointer inside the open file to position. If position_type is 0, it seeks from the start. If position_type is 1, it seeks from the current position. If position_type=2 it seeks from the end
fseropen number baudrate, optional number blocking number handle Opens the serial port at the specified baud rate
fsockopen string host, optional number timeout Number handle Attempts to create a socket to the host with the protocol specified and returns a handle or 0 if failed
ftell int file handle int file position Returns the current file position of the open file
function_exists string funcname int result Checks if a function (custom or native) exists and returns 1 if so
fwrite number handle, mixed value number of bytes written or -1 for error writes data to the stream or file
get3gstat   array Returns an array of the status of the USB Dongle network interface
getcwd   string Gets the current directory
getethstat   array Returns an array of the status of the LAN interface
getmac   string Returns the network MAC address
getusbstat   array Returns information about the USB host status
header string none add to http header
htmlspecialchars string string convert characters for display in html
ieee754toint float int Takes a floating point value and returns it as an IEEE-754 encoded integer (32 bit)
implode array, string separator string Implodes the array with the separator and returns a string
include string filename none includes a file within the current script at the current location
indexed_array int type,int size array returns an array of [size] element of [type] (1=byte,2=short,3=int,4=float)
ini_get string ini, string section, string key, mixed defvalue mixed returns the value associated with the key if it exists, or the default value otherwise
ini_get_array string ini, string section array returns a key/value array of all items in the section
ini_put_array string ini, optional string section   writes the values in the key/value array to the ini file or to the section inside, if specified.
ini_set string ini, string section, string key, mixed value number (1=OK) writes the value to the section in an INI file
inttoieee754 float int Takes an IEEE-754 encoded integer (32 bit) and returns a float
intval string or float number integer value of the parameter
is_array mixed value number Returns 1 if the variable or value is an array
is_float mixed value number Returns 1 if the variable or value is a floating point value
is_int mixed value number Returns 1 if the variable or value is an integer
is_numeric mixed value number Returns 1 if the value is numeric (integer or float)
is_string mixed value number Returns 1 if the variable or value is a string
isset variable number Returns 1 if the variable exists or 0 if not
json_encode array,type [0=object,1=array) string encode an array as a string
ln number float return natural logarithm of number
log string none print to log
log10 number float return log10 of number
mail string recipient, string title, string body number 0=success, other number contains SMTP error code
max_execution_time number   set maximum execution time in seconds
mb_add_dev number device_id, number device_type_id, string name, number poll_interval, number status Number (0=OK) adds a device to the list of polled devices
mb_delete_device number device_id number (1=OK) delete a device from the list of active device with the slave ID passed
mb_get_dev_by_id number id array modbus device details
mb_get_dev_by_index number index array modbus device details
mb_get_dev_by_name string name array modbus device details
mb_get_dev_info number device type id array modbus device details
mb_get_role_array   array array of all roles and their values
mb_get_status_by_role number role_id number (1=OK) status of the device attached to the role
mb_get_val_by_role number role_id number value of the role in the system
mb_num_devices   number number of devices on the modbus
mb_scan_complete   number 1=complete, 0=ongoing
mb_scan_percent   number percentage completed of scan
mb_send_command mixed, multiple parameters array of numbers send a sequence of characters to the rs485 bus and get reply
mb_queue_command mixed, multiple parameters array of numbers queue a sequence of characters to the rs485 bus and get but ignore reply
mb_set_dev_var string or number device name or id, param string, value number, 1=OK set a variable on a modbus device
mb_set_val_by_role number role_id, number value number, 1=OK set a role value on a modbus device
mb_start_scan number start, number end   initiates an automatic scan of modbus bus
md5 string src string[32] calculates the MD5 hash of the string
md5_file string filename string[32] calculates the MD5 hash of the file
mem_dump   none writes the current memory map to /dump.txt
mem_usage   none writes memory usage to standards output
microtime   number number of milliseconds since boot
mkdir string number FR_OK or erro code
mktime number hr,min,sec,month,day,year number linux timestamp of date
net_disable3g     Disable usb dongle net connectivity
net_enable3g     Enabled usb dongle net connectivity if available
netstat   array returns information about the current http connections
number_format mixed num, number digits string formats the number with the specified number of digits of precision
nvram_backup string filename   writes contents of nvram to the file in filename
nvram_defrag     defragments nvram if required
nvram_dump     dumps the contents of nvram to the standard output
nvram_free   number number of free bytes in nvram
nvram_get string key, mixed def_value string returns the value of the key in nvram, or the def_value if not yet assigned
nvram_restore string filename   reads contents of filename into nvram
nvram_set string key, string value   sets a key and value in nvram
nvram_unset string key   clears a key from nvram
ord string char number num Returns the ASCII number of the character
ow_first   array Initiates a onewire scan and returns the first device found
ow_next   array Returns the next device found or 0 if none
ow_read   number val Reads a byte from the onewire bus
ow_read_temp optional array number Returns the temperature in degrees celcius for the device
ow_reset     Resets the onewire bus
ow_write number val   Writes a byte to the onewire bus
phpinfo   string returns information about the system
pin_configure number pin, number pin_type   configures an IO pin as a digital input, output, or analog input
pin_get number pin number get the value of digital input pin
pin_set Number pin_number, number value   sets a digital output to value (1 or 0)
ping string host array sends an ICMP ping and puts the result in the array
power number num, number factor number returns num to the power of factor
print mixed   output data to the current output stream such as web page or terminal
print_r array   dump the contents of an array to the current output
printf string format, optional values   prints a formatted string to the standard output
process_kill number process_id   sends a kill request to the process number
process_list   array returns an array of the currently running scripts
rand int min, int max int Returns a pseudo-random number between min and max
reboot     Resets the processor
rename string source, stirng dest number Renames or moves a file from source to dest name
reset     If passed with 0 parameters, equivalent to reboot
rmdir string dir number Removes a directory, returns 0 if successful
session_destroy     clears the current sessions data
session_is_new   number Returns 1 if the session is just initiated
session_start     initiates a new session and sends the cookie data for it
set_search_path string   sets the search path for the telnet client
setethpower number   Enables or disables the ethernet controller
setpriority number   sets the priority of the script (2 is high, 1 is low)
settime number   Set system from linux timestamp
setusbpower number   sets the USB host power on or off (1 or 0)
sha1 string src string[40] calculates the SHA1 hash of the string
sin number number Returns the sin value of the number
sizeof array number returns the number of elements in an array
sleep number   Sleep for specified milliseconds
spi_clearcs     clears the CS output of the SPI bus
spi_read   number reads a byte from the SPI bus
spi_setcs     sets the CS output of the SPI bus
spi_write number   writes a byte to the SPI bus
sprintf string format, optional values string formats a string using the format specified using the passed parameters and returns a string
sqr number number Returns the square of a number
sqrt number number Returns the square root of a number
stats   array Returns system statistics
strftime string format, number time string formats the passed time using the format string
strlen string str number Returns the length of a string
strpos string haystack, string needle number Returns the position of the first occurence of needle in haystack or -1 if not found
strrpos string haystack, string needle number Returns the last occurence of haystack in needle, or -1 if not found
strtolower string string returns the lowercase version of the string
strtoupper string string returns the uppercase version of the string
strval Mixed value string Returns the string value of the passed parameter
substr string str, number start, number len string returns a substring of the passed string from start for len characters. If len is blank it will return the string until the end
tar_finish number handle   adds the ending header to a TAR file
tar_put number handle, string filename number (1=OK) adds a file to the currently open file handle in TAR format
time   number Returns the current system timestamp
timefromfat number number converts a FAT filetime to a native timestamp
ucfirst string string convert string to lowercase except for first character
unlink string filename Number (0=OK) removes a file (deletes it)
untar string filename, number verbose   untars a file into the current folder, optionally verbose
uptime   number uptime in milliseconds