Vollzeitblogger

PHP.js, PHP Funktionen in JavaScript

January 23, 2014

Der Funktionssatz, der bei PHP standardmäßig dabei ist, ist anders und auch größer als der von JavaScript. Einige Entwickler haben die PHP Funktionen in JavaScript implementiert und das Projekt PHP.js getauft.

Dem Initiator zufolge ist PHP.js:

For PHP developers that want see how it’s done in JavaScript

That enables fun experiments

With a few higher level functions that are incredibly useful, and missing in JavaScript

Es ist also mehr Experiment und Referenz als für den Einsatz in der Praxis oder im Frontend, da die Bibliothek über 2MB in Beschlag nimmt.

Besonders anschaulich sind die Beispiele für Hashalgorithmen wie für die Übertragung von PHP’s SHA1 Funktion.

Kevin van Zonneveld beschreibt außerdem auf der Projektseite, dass mögliche Experimente das Ausführen von PHP mit JavaScript wären und das Schreiben der Funktionen ihm beim Erlernen von JavaScript sehr geholfen hat. Wenn ihr aus der PHP Ecke kommt, schaut doch mal wie die Funktionen geschrieben sind und ob JavaScript vielleicht etwas für euch ist!

Komplette Liste der Funktionen von PHP.js

array

array arraychangekeycase arraychunk arraycombine arraycountvalues arraydiff arraydiffassoc arraydiffkey arraydiffuassoc arraydiffukey arrayfill arrayfillkeys arrayfilter arrayflip arrayintersect arrayintersectassoc arrayintersectkey arrayintersectuassoc arrayintersectukey arraykeyexists arraykeys arraymap arraymerge arraymergerecursive arraymultisort arraypad arraypop arrayproduct arraypush arrayrand arrayreduce arrayreplace arrayreplacerecursive arrayreverse arraysearch arrayshift arrayslice arraysplice arraysum arrayudiff arrayudiffassoc arrayudiffuassoc arrayuintersect arrayuintersectassoc arrayuintersectuassoc arrayunique arrayunshift arrayvalues arraywalk arraywalkrecursive arsort asort compact count current each end inarray key krsort ksort natcasesort natsort next pos prev range reset rsort shuffle sizeof sort uasort uksort usort bc

bcadd bccomp bcdiv bcmul bcround bcscale bcsub ctype

ctypealnum ctypealpha ctypecntrl ctypedigit ctypegraph ctypelower ctypeprint ctypepunct ctypespace ctypeupper ctype_xdigit datetime

checkdate date date_parse getdate gettimeofday gmdate gmmktime gmstrftime idate microtime mktime strftime strptime strtotime time exec

escapeshellarg filesystem

basename dirname filegetcontents pathinfo realpath funchand

calluserfunc calluserfuncarray createfunction functionexists getdefined_functions i18n

i18nlocgetdefault i18nlocsetdefault info

assertoptions getenv getlastmod iniget iniset settimelimit versioncompare json

jsondecode jsonencode jsonlasterror math

abs acos acosh asin asinh atan atan2 atanh baseconvert bindec ceil cos cosh decbin dechex decoct deg2rad exp expm1 floor fmod getrandmax hexdec hypot isfinite isinfinite isnan lcgvalue log log10 log1p max min mtgetrandmax mt_rand octdec pi pow rad2deg rand round sin sinh sqrt tan tanh misc

pack timesleepuntil uniqid net-gopher

gopher_parsedir network

inetntop inetpton ip2long long2ip setcookie setrawcookie pcre

preggrep pregquote sql_regcase strings

addcslashes addslashes bin2hex chop chr chunksplit convertcyrstring convertuuencode countchars crc32 echo explode gethtmltranslationtable htmlentitydecode htmlentities htmlspecialchars htmlspecialcharsdecode implode join lcfirst levenshtein localeconv ltrim md5 md5file metaphone moneyformat nl2br nllanginfo numberformat ord parsestr printf quotedprintabledecode quotedprintableencode quotemeta rtrim setlocale sha1 sha1file similartext soundex split sprintf sscanf strgetcsv strireplace strpad strrepeat strreplace strrot13 strshuffle strsplit strwordcount strcasecmp strchr strcmp strcoll strcspn striptags stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk strpos strrchr strrev strripos strrpos strspn strstr strtok strtolower strtoupper strtr substr substrcompare substrcount substrreplace trim ucfirst ucwords vprintf vsprintf wordwrap url

base64decode base64encode getheaders getmetatags httpbuildquery parseurl rawurldecode rawurlencode urldecode urlencode var

doubleval empty floatval gettype intval isarray isbinary isbool isbuffer iscallable isdouble isfloat isint isinteger islong isnull isnumeric isobject isreal isresource isscalar isstring isunicode isset serialize settype strval unserialize vardump varexport xdiff

xdiffstringdiff xdiffstringpatch xml

utf8decode utf8encode


© 2023, by Jonathan M. Hethey