Funções similares as do PHP

LUA
Enviado por Eclesiastes em Seg, 05/02/2007 - 22:51.LUA

Olá pessoal, estreiando essa nova seção no PHPAvançado, preparei uma lista de funções built-in da linguagem Lua que há similaridade com as do PHP. Pois para quem está iniciando, acredito que seja importante conhecê-las.

Vamos lá!

print() - print / echo

String

string.char() - chr()
string.byte() - ord()
string.format() - sprintf()
string.len() - strlen()
string.sub() - substr()
string.upper() - strtoupper()
string.lower() - strtolower()
string.rep() - str_repeat()
string.find() - strpos()
string.gfind() - ereg()
string.gsub() - ereg_replace()

Tabela (Array)

table.concat() - join()
table.getn() - count()
table.setn() - $arr[chave] = 'valor';
table.insert() - array_push()
table.remove() - unset()
table.sort() - sort()

Matemática

math.randomseed() - srand()
math.random() - rand()
math.min() - min()
math.max() - max()
math.log() - log()
math.log10() - log10()
math.cos() - cos()
math.sin() - sin()
math.tan() - tan()
math.acos() - acos()
math.asin() - asin()
math.atan() - atan()
math.atan2() - atan2()
math.deg() - rad2deg()
math.rad() - deg2rad()
math.abs() - abs()
math.sqrt() - sqrt()
math.ceil() - ceil()
math.floor() - floor()
math.mod() - %

Entrada e saída

io.open() - fopen()
io.write() - fwrite()
io.read() - fread()
io.lines() - file()
io.seek() - fseek()
io.popen() - popen()
io.close() - fclose()

Operando no sistema

os.setlocale() - setlocale()
os.remove() - unlink()
os.rename() - rename()
os.tmpfile() = tmpfile()
os.tmpname() - tempnam()
os.time() - mktime()
os.date() - date()
os.getenv() - getenv()
os.execute() - exec()