Lompat ke isi

Panduan Praktis PHP/Operasi variabel

Dari Wikibuku bahasa Indonesia, sumber buku teks bebas

Perbandingan bahasa operasi variabel pada PHP dan Gambas:

PHP Gambas
$i = $i + 1; i = i + 1
$i++; i += 1
$i = $i - 1; i = i - 1
$i--; i -= 1
$i3 = $i1 * $i2; i3 = i1 * i2
$i3 = $i1 / $i2; i3 = i1 / i2
$i3 = $i1 % $i2; i3 = i1 Mod i2
$str3 = $str1 . $str2; str3 = str1 & str2
$str2 = str_replace($cari1, $cari2, $str1); str2 = Replace(str1, cari1, cari2)
$i = strpos($str, $cari); i = InStr($str, $cari)
$i = mb_strpos($str, $cari, 0, "UTF-8"); i = String.InStr($str, $cari)
$substr = substr($str, $start, $len); strMid = Mid(str, intStart, intLen)
$substr = mb_substr($str, $start, $len, "UTF-8"); strMid = String.Mid(str, intStart, intLen)
$arr = explode($separator, $str); arr = Split(str, strSeparator)
$arr[0] arr[0]
$trimmed = trim($str); strTrimmed = Trim(str)
$trimmed = ltrim($str); strTrimmed = LTrim(str)
$trimmed = rtrim($str); strTrimmed = RTrim(str)
$i = strlen($str); i = Len(str)
$i = mb_strlen($str, "UTF-8"); i = String.Len(str)
$code = ord($str); intCode = Asc(str)
$str = chr(code); str = Chr(intCode)
$code = mb_ord($str); intCode = String.Asc(str)
$str = mb_chr(code); str = String.Chr(intCode)
$i = intval($str); i = Int(str)
$str = strval($i); str = Str(i)