0.0.3 • Published 4 years ago

php-as-js v0.0.3

Weekly downloads
80
License
MIT
Repository
github
Last release
4 years ago

PHP-AS-JS

A JavaScript library that enables some PHP function for browsers.

addclass (_element, ...)
TypeParametersDescriptionOptional
{element}elementHTML element to add class on
{arraystring}...Array or string of the class

Returns {element}
The element with class added

date (format, timestamp)
TypeParametersDescriptionOptional
{string}formatSupport PHP date format
{number}timestampUses current time if not givenYes

Returns {string}
A formatted according to the given format

dayof_year (_var)
TypeParametersDescriptionOptional
{date}varA valid date object

Returns {number}
The day of the year

empty (var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if empty, otherwise FALSE

getelement (_qs)
TypeParametersDescriptionOptional
{string}qsQuery selector

Returns {element|null}
The element if valid, otherwise NULL

getelements (_qs)
TypeParametersDescriptionOptional
{string}qsQuery selector

Returns {array|null}
An array of the elements if valid, otherwise NULL

gettype (var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {string}
The type of the given variable

md5 (var)
TypeParametersDescriptionOptionalCredit
{any}varThe variable to hashPaul Johnston

Returns {string}
An MD5 hashed string

inarray (_needle, haystack, strict)
TypeParametersDescriptionOptional
{any}needleThe value to search
{array}haystackThe array to be searched
{boolean}strictDetermine to check types

Returns {boolean}
TRUE for found in the given array, otherwise FALSE

intval (var, base)
TypeParametersDescriptionOptional
{any}varThe variable to convert
{number}baseDefault is 10 for decimal output and 16 for hex outputYes

Returns {number|string}
A converted decimal integer, or a hex string

isarray (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if an array, otherwise FALSE

isbool (_var)

| {any} | var | The variable to check | |

Returns {boolean}
TRUE if a boolean, otherwise FALSE

isfloat (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if a float, otherwise FALSE

isint (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if an integer, otherwise FALSE

isleap_year (_var)
TypeParametersDescriptionOptional
{any}varThe year number to check

Returns {boolean}
TRUE if a leap year, otherwise FALSE

isnull (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if NULL, otherwise FALSE

isobject (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if an object, otherwise FALSE

isstring (_var)
TypeParametersDescriptionOptional
{any}varThe variable to check

Returns {boolean}
TRUE if a string, otherwise FALSE

monthname (_n, short)
TypeParametersDescriptionOptional
{number}nThe month number which is an integer between 0 and 11
{boolean}shortDetermine if returns the first 3 letters or full namesYes

Returns {string}
The name of the month

sprintf (format, ...)
TypeParametersDescriptionOptional
{string}formatSupports %s only at the moment
{string}...variables to replace the format

Returns {string}
The replaced string

ucfirst (str)
TypeParametersDescriptionOptional
{string}strSource string

Returns {string}
The string with the first letter converted to uppercase

uniqid (len)
TypeParametersDescriptionOptional
{number}lenThe length of the generated hex string

Returns {string}
The generated hex string

weekname (_n, short)
TypeParametersDescriptionOptional
{number}nWeek number between 0 and 6
{boolean}shortDetermine if return the first 3 letters or full names

Returns {string}
The name of the week

weeknumber (_obj)
TypeParametersDescriptionOptional
{date}objDate object

Returns {number}
The week number in the year