JavaScript and PHP
출처: http://blog.naver.com/bluebuck0107/120014903490
javascript | php |
typeof(string1)=="string" | is_string(string1); |
string1.length | strlen(string1); |
String.fromCharCode(fromNum) fromChar.charCodeAt(0) |
chr(fromNum); ord(fromChar); |
string1.toLowerCase() string1.toUpperCase() |
strtolower(string1); strtoupper(string1); |
string1.indexOf( string2, fromNum ) | strpos( string1, string2, fromNum ); |
string1.charAt(number) | substr(string1, number, 1); |
string1.lastIndexOf( string2, fromNum ) | function strposr($string='', $search='', $case=0){ if(!$case){$string=strtolower($string); $search=strtolower($search);}; return ( strpos($string, $search)===false )?false: strlen($string) - strlen($search) - (strpos( strrev($string), strrev($search))); } |
string1.substring( fromNum, toNum ) | substr( string1, fromNum, (toNum-fromNum) ); |
string1.substr( fromNum, length ) | substr( string1, fromNum, length); |
string1.substr(fromNum, length) string1.substring( fromNum, (fromNum+length) ) |
substr( string1, fromNum, length ); |
string1.substring( string1.indexOf(string2) ) | strstr( string1, string2 ); |
string1.split(stringSplitter) | explode(stringSplitter, string1); |
string1.replace( findThis, replaceWithThis ) | str_replace( findThis, replaceWithThis, string1 ); |
string1.replace( regularExpression, replaceWithThis ) | preg_replace( regularExpression, replaceWithThis, string1 ); |
string1.replace( string1.substring( fromNumIndex, (fromNumIndex+length) ), replaceWithThis ) | substr_replace( string1, replaceWithThis, fromNumIndex, length ); |
string1=string1.replace(/<[^>]*>/g, ''); | string1=striptags(string1); |
string1.replace( findThis, replaceWithThis ) | str_replace( findThis, replaceWithThis, string1 ); |
string1.replace( regularExpression, replaceWithThis ) | preg_replace( regularExpression, replaceWithThis, string1 ); |
string1.replace( string1.substring( fromNumIndex, (fromNumIndex+length) ), replaceWithThis ) | substr_replace( string1, replaceWithThis, fromNumIndex, length ); |
typeof(array1)=="object" | is_array(array1) |
array1.length | sizeof(array1); |
array1.join(stringJoiner) | implode(stringJoiner, string1); |
array1.concat(array2, array3...) | array_merge(array1, array2, array3...); array_merge_recursive(array1, array2, array3...); |
shift() | array_shift(array1); |
unshift() | array_unshift(array1); |
pop() | array_pop(array1); |
push() | array_push(array1); |
array1.reverse() | array_reverse(array1); |
array1.slice(startIndex, endIndex) | array_slice( array1, startIndex, (endIndex-startIndex) ); |
array1.splice(startIndex, length) | array_splice( array1, startIndex, length ); |
array1.slice(startIndex, (startIndex+length)) | array_slice( array1, startIndex, length ); |
array1.splice(startIndex, length) | array_splice( array1, startIndex, length ); |
array1.sort | sort(array1); |
isNaN(number) | is_nan(number); is_numeric(number); is_integer(number); is_double(number); |
parseInt(string) | (integer)string; |
parseFloat(string) | (double)string; |
Math.max(number1, number2) | max(number1, number2); |
Math.min(number1, number2) | min(number1, number2); |
(Math.random()*(max-min))+min | mt_rand(min, max); |
Math.round( (Math.random()*(max-min))+min ) |
mt_srand((double)microtime()*1000000) |
Math.pow(number, power) | pow(number, power); |
Math.sqrt(number) | sqrt(number); |
Math.sin(); | sin(); |
Math.cos(); | cos(); |
Math.tan(); | tan(); |
Math.asin(); | asin(); |
Math.acos(); | acos(); |
Math.atan(); | atan(); |
Math.PI; | pi(); |
Math.log(value) | log(value); |
typeof(functionName)=="function"; | function_exists("functionName"); |
functionName.arguments.length; | func_num_args(); |
functionName.arguments; | func_get_args(); |
functionName.arguments[Number]; | func_get_arg(Number) |
'JavaScript' 카테고리의 다른 글
[JavaScript] 팝업창 크기의 한계 (0) | 2009.07.02 |
---|---|
[JavaScript] Event, Element, Handler (0) | 2009.07.01 |
[JavaScript] cookie (0) | 2009.07.01 |
[JavaScript] String 객체의 character position 관련 함수 (0) | 2009.06.24 |
[JavaScript] select의 선택된 option의 value, text 가져오기 (4) | 2009.06.24 |