User Tools

Site Tools


uphp:functions

This is an old revision of the document!


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.

Click on the function name for further details:

FUNCTION NAMEPARAMETER(S)RETURNDESCRIPTION
adc_readint channelint ADC valueRead an onboard ADC channel
aes_decryptstring text, int length, string key, string ivstring with dataReturn an AES-decrypted string
aes_encryptstring text, int length, string key,string ivstring with dataReturn an AES-encrypted string
arraymixed values ...arrayCreate an array, with optional values
array_keyarray, int indexstring keyReturn the key for an array index
array_keysarray with key/value pairsarray of keysReturn keys for an array that has key/value pairs
base64_decodestring base64string decoded or int 0Decode a base64-encoded string
base64_encodestring to encodestring base64 or int 0Return the base64-encoded version of a string
call_user_funcstring function_name, mixed parameters ...mixed resultCall a user defined function with optional parameters
charatstring, int indexint ASCII codeReturn the ASCII code for a character in a string at an index
chdirstring directoryint 0=OKChange the current directory
chrint codestring 1 characterReturn the character for an ASCII code
clear_watchdogClear the software watchdog timer
cosnumber radian_anglefloat cosineReturn cosine of a radian_angle
debugstring outputPrint to debug output
debugoutint 0 or 1Enable or disable debug messages
dieKill the script
disk_free_spaceint driveint KiloBytesReturn free space on drive
disk_statusint driveint StatusReturn mount status of drive
disk_total_spaceint driveint KiloBytesReturn total space on drive
error_reportingint verbositySet the debug output level
execstring script, int delayRun a script with an optional delay
exec_actionmixed actionint 1=OKTriggers a manually executable action by id or name
explodestring, string delimiterarrayTurn a string into an array
f485openint baud, int parityint handle or 0Open the RS-485 port at the specified baud rate and parity
fcloseint handleClose a file, stream or socket
feofint handleint 1 or 0Test if no more data is available in a file, stream or socket
fgetsint handle, int sizestring or int -1Return a single line from a file, stream or socket, with optional size limit
file_existsstring filenameint 1 or 0Check if a file exists
filesizestring filename or int handleint bytesReturn the size of a file, or the number of unread bytes in a stream or socket
findfirststring pattern, int attributesarray first file foundStart searching the current folder for files matching a pattern and attributes
findnextarray next file foundReturn next matching file information (after a findfirst)
firmwareupdateInitiate a firmware update sequence and reboot the device
floatvalmixed valuefloat value or int 0/1Return the float value of a number or string
flushsocket socket to flushFlush current output or socket to the browser
fopenstring filename, string modeint handle or 0Open a file for reading or writing
freadint handle, int bytesstring or int 0Read bytes from a file, stream or socket
freememint bytesReturn free memory space
freestackint bytesReturn free stack space
fseekint handle, int offset, int whencePosition the file pointer in an open file
fseropenint baud, int blocking, int invert, int parityint handle or 0Open the serial port at the specified baud rate with optional parameters
fsockopenstring host, int port, int timeoutint handle or 0Open an internet socket connection with optional timeout
ftellint handleint positionReturn the current position of a file read/write pointer
ftp_commandstring resultstring command]Send an FTP command
ftp_closeint resultClose an active connection with FTP server
ftp_downloadint resultstring remote_file,string local_file,[int position]Initiate a download of a remote file
ftp_errorint resultGet last FTP response code
ftp_is_busyint result Check if the FTP engine is busy
ftp_is_connectedint result Check if the FTP connection is active
ftp_is_connectingint result Check if the FTP connection is in the process of connecting
ftp_listint resultstring folder, string output_fileLists a folder on the FTP server and outputs the result to the specified file
ftp_openint resultstring host, int port, string username, string passwordOpen a connection to an FTP server
ftp_sizeint sizestring filenameGet the file size of a file on the FTP server
ftp_statusarray status
ftp_uploadint resultstring remote_file,string local_file,[int position]Initiate an upload of a file
function_existsstring function_nameint 1 or 0Check if a function exists (custom or native)
fwriteint handle, mixed data, int lengthint bytes written or -1Write data to a file, stream or socket
get3gstatarrayGet cellular data connection status information
getcwdstring pathGet the current directory
getethstatarrayGet Ethernet connection status information
getmacstring MACGet the Wattmon's MAC address
getusbstatarrayGet USB host status information
getwifistatarrayGet WIFI status information
headerstring header_dataAdd to HTTP header
hash_hmacstring algorithm, string data, string key string convertedGenerate a keyed hash value using the HMAC method
htmlspecialcharsstring datastring convertedConvert special characters for display in HTML
ieee754tointfloat valueint representationConvert a float value to an IEEE-754 encoded integer (32 bit)
implodearray, string delimiterstringTurn an array into a string
includestring filenameInclude a file within the current script at the current location
indexed_arrayint type, int sizearrayCreate an array of a specific type and size
ini_getstring filename, string section, string key, mixed defaultmixed valueGet a value from an INI file
ini_get_arraystring filename, string sectionarrayGet a group of parameters from an INI file as an array
ini_put_arraystring filename, array data, string sectionWrite a group of parameters to an INI file from an array
ini_setstring filename, string section, string key, mixed valueint 1=OKSet a value in an INI file
init_watchdogint intervalInitialize the software watchdog timer
inttoieee754int representationfloat valueConvert an IEEE-754 encoded integer representation (32 bit) to a float
intvalmixed valueint valueReturn the integer value of a number or string
is_arraymixed variableint 1 or 0Check if a variable is an array
is_floatmixed variableint 1 or 0Check if a variable is a float
is_intmixed variableint 1 or 0Check if a variable is an integer
is_numericmixed valueint 1 or 0Check if a value is numeric (int, float or numeric string)
is_stringmixed variableint 1 or 0Check if a variable is a string
issetmixed variableint 1 or 0Check if a variable exists
json_encodearray, int methodstringJSON encode an array into a string, with optional method
lnnumber numberfloat logeReturn the natural logarithm of a number
logstring output, string filePrint to the System Log (or optional file)
log10number numberfloat log10Return the base 10 logarithm of a number
mailstring recipient, string subject, string bodyint 0 or SMTP error codeSend an email [deprecated]
max_execution_timeint secondsSet the maximum execution time for the current script
mb_add_devint id, int type, string name, int poll_interval, int status, int busint 0=OKAdd a device to the list of polled devices
mb_delete_devint idint 1=OKDelete a device from the list of active devices
mb_get_dev_by_idint idarrayReturn modbus device details by id
mb_get_dev_by_indexint indexarrayReturn modbus device details by index
mb_get_dev_by_namestring namearrayReturn modbus device details by name
mb_get_dev_infoint typearrayReturn modbus device details by type
mb_get_role_arrayarrayReturn an array of all roles and their values
mb_get_status_by_roleint roleint 1=OKReturn status of the device attached to the role
mb_get_val_by_roleint rolenumberReturn value of the role
mb_num_devicesintReturn number of devices on the modbus
mb_queue_commandmixed values ...array of numbersQueue a sequence of characters to the RS-485 bus and get but ignore the reply
mb_scan_completeint 1=complete, 0=ongoingCheck to see if a modbus scan has completed
mb_scan_percentnumber percent completedReturn scan percentage completed
mb_send_commandmixed values ...array of numbersSend a sequence of characters to the RS-485 bus and get a reply
mb_set_dev_varstring name or int id, string variable, mixed valueint 1=OKSet a variable on a modbus device
mb_set_val_by_roleint role, number valueint 1=OKSet a role value on a modbus device
mb_start_scanint start, int endInitiate an automatic scan of the modbus
md5string inputstring 32 charactersCalculate the MD5 hash of a string
md5_filestring filenamestring 32 charactersCalculate the MD5 hash of a file
mem_dumpWrite the current memory map to /dump.txt
mem_usageWrite memory usage to standard output
microtimeint msReturn the number of milliseconds since boot
mkdirstring pathnameint 0 or error codeMake a directory
mktimeint hour, int minute, int second, int month, int day, int yearint secondsReturn the Linux Timestamp for a given date and time
mqtt_disconnectDisconnect MQTT connection
mqtt_publishstring channel, string contentint 1 for success or 0 for errorPublish a message to an MQTT server
mqtt_subscribestring channel, string callbackint 1 for success or 0 for errorSubscribe to a channel on an MQTT server
mqttstatarray array with connection statusGet MQTT Connection status
net_disable3gDisable 3G support for the dongle
net_enable3gEnable 3G support for the dongle
netstatarrayGet Ethernet information
number_formatmixed number, int digitsstring formattedReturn the string value of a number formatted to a particular precision
nvram_backupstring filenameint bytes written or 0=errorBackup the contents of NVRAM to a file on the SD Card
nvram_defragDefragment NVRAM to optimise it
nvram_dumpDump the contents of NVRAM to standard output
nvram_freeint bytesReturn the number of bytes available in NVRAM
nvram_getstring keymixed valueGet a value from NVRAM
nvram_restorestring filenameRestore the contents of NVRAM from a file
nvram_setstring key, string valueint 1=OKSet a key and value in NVRAM
nvram_unsetstring keyint 1=OKClear a key from NVRAM
ordstring characterint ASCII codeReturn the ASCII code for a character
ow_firstarray or int 0Initiate a OneWire bus scan and return the address of the first device found
ow_nextarray or int 0Return the address of the next OneWire device found (after an ow_first)
ow_readint value or 0Read a byte from the OneWire bus
ow_read_temparray device_idfloat degrees CelsiusRead a temperature from a device on the OneWire bus
ow_resetReset the OneWire bus
ow_writeint valueWrite a byte to the OneWire bus
packstring format, mixed value stringPack a value into a string
phpinfostringReturn information about the system
pin_configureint pin_index, int pin_type, int counter_typeConfigure an I/O pin as a digital input, output, or analog input
pin_getint pin_index, int pin_typeint valueReturn the value of an I/O pin
pin_setint pin_index, int valueSet a digital output to value 1 or 0
pingstring hostarraySend an ICMP ping and place the result in an array
powernumber base, number expnumber baseexpReturn base raised to the power of exp
printstring dataPrint data to the current output stream such as a web page or terminal
print_rarrayDump the contents of an array to the current output
printfstring format, mixed values ...Print a formatted string to standard output
process_killint pidSend a kill request to a process
process_listarrayReturn an array of the currently running scripts
randint min, int maxintReturn a random integer between min and max
rebootReboot the processor
register_callbackstring callback_type, string filename, string functionnameint 0 or error codeRegister a callback function for system events
renamestring source, string destinationint 0 or error codeRename or move a file or directory from source to destination
resetReset the processor
rmdirstring pathname, int delete_contentsint 0=OKRemove a directory, with optional deletion of contents
send_smsstring phone_number, string messageint resultsends an sms through a cellular dongle
session_destroyClear the current session's data
session_is_newintCheck if a session was just initiated
session_startInitiate a new session and send the cookie data for it
set_search_pathstring pathnameSet the search path for the telnet client
setethpowerint stateEnable or disable the ethernet controller
setpriorityint prioritySet the priority of the current script
settimeint timestamp, int calibrationSet the system time from a Linux Timestamp, with optional calibration
setusbpowerint stateEnable or disable USB power
sha1string inputstring 40 charactersCalculate the SHA1 hash of a string
sinnumber radian_anglefloat sineReturn sine of a radian_angle
sizeofarrayint number of elementsReturn the number of elements in an array
sleepint msSleep for specified milliseconds
spi_clearcsClear the CS output of the SPI bus
spi_readint byteRead a byte from the SPI bus
spi_setcsSet the CS output of the SPI bus
spi_writeint byteWrite a byte to the SPI bus
sprintfstring format, mixed values ...string formattedReturn a formatted string
sqrnumber numbernumber squaredReturn the square of a number
sqrtnumber numbernumber square rootReturn the square root of a number
statsarrayReturn system statistics
strftimestring format, int timestampstring formattedFormat a Linux Timestamp using a format string
strlenstring inputint lengthReturn the length of a string
strposstring haystack, string needleint position or -1Return the position of the first occurrence of a needle in a haystack
strrposstring haystack, string needleint position or -1Return the position of the last occurrence of a needle in a haystack
strtolowerstring inputstring lowercaseReturn the lowercase version of a string
strtoupperstring inputstring UPPERCASEReturn the UPPERCASE version of a string
strvalmixed valuestringReturn the string equivalent of a number
substrstring input, int start, int lengthstring substringReturn part of a string
tar_finishint handleint 1=OKAdd the ending header to a TAR file
tar_putint handle, string src_pathname, string tar_pathnameint 1=OKAdd a file to an open file in TAR format
timeint secondsReturn the current system timestamp
timefromfatint filetimeint secondsConvert a FAT filetime to a Linux Timestamp
trimstring inputstring trimmedReturn the trimmed string
ucfirststring inputstring LowercaseConvert a string to Lowercase except for the first character
unlinkstring filenameint 0 or error codeRemove a file (delete it)
untarstring filename, int verbosityint 1=OKExpand a TAR file into the current folder, optionally verbose
unpackstring format, string value numberUnpack a packed string value and return the original data
uptimeint msReturn the uptime in milliseconds
wifi_disableDisable Wifi module
wifi_enableEnable Wifi module
uphp/functions.1576833754.txt.gz · Last modified: 2021/09/13 05:56 (external edit)