ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç
ȨÆäÀÌÁö Á¦ÀÛ±âÃÊ
±âº»Å±×
ÅÂ±×ÆÁ¸ðÀ½
ű×ÀÚ·á¹æ
Æ÷Åä¼¥°ÁÂ
À¥.°ü·Ã°ÁÂ
PHP°ÁÂ
PHPÆÁ
HTML.CSS
JAVASCRIPT
ASP
JSP
PHP½ÉÈ
C.C++
Ç÷¡½Ã.ActionScript
ÀÚÀ¯°Ô½ÃÆÇ
Áú¹®°Ô½ÃÆÇ
À¯¸Ó°Ô½ÃÆÇ
¿À¶ô½Ç
Tel. 042-353-2371
ÆòÀÏ ¿ÀÀü 9½Ã ~ ¿ÀÈÄ 7½Ã
±â¾÷ÀºÇà
010-8649-6758
¿¹±ÝÁÖ:Á¦ÁÖ»ç¶û(¼ÛÁø¾Æ)
PHP
Ȩ > ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç > PHP
ÀÛ¼ºÀÚ
freeweb
Ä«Å×°í¸®
PHP
Ŭ·¡½º&ÇÔ¼ö
CUBRID
PC
DB
Á¦·Îº¸µå
ÃʱÞ
MYSQL
CGI
ºñ¹Ð¹øÈ£
Á¦¸ñ
<BR><BR>1. Variable (º¯¼ö) <BR>- º¯¼ö´Â $·Î ½ÃÀÛÇÑ´Ù. <BR><BR>- º¯¼ö´Â º°µµ·Î ¼±¾ðÇÏ´Â ºÎºÐÀÌ ¾øÀ¸¸ç (typeÀ» ¹Ì¸® ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸ç) º¯¼ö typeÀº º¯¼ö°¡ »ç¿ëµÈ context¿¡ µû¶ó °áÁ¤µÈ´Ù. <BR><BR>- º¯¼öÀÇ typeÀ¸·Î´Â ±âº»ÀûÀ¸·Î integer, double, string typeÀÌ ÀÖÀ¸¸ç À̿ܿ¡ array¿Í object typeÀÌ ÀÖ´Ù. º¯¼ö typeÀº gettype(), is_long(), is_double(), is_string(), is_array(), is_object() µîÀÇ ÇÔ¼ö·Î ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù. <BR><BR>- type castingÀº C¿¡¼¿Í °°Àº Çü½ÄÀ¸·Î ÀÌ·ç¾îÁø´Ù. (int) (integer) (real) (double) (float) (string) (array) (object) µîÀÇ casting operator°¡ ÀÖ´Ù. <BR><BR>- string conversion : ¹®ÀÚ¿ÀÌ ¼ýÀÚ·Î º¯È¯µÉ ¶§¿¡ ¹®ÀÚ¿ÀÌ '.', 'e', 'E'¸¦ Æ÷ÇÔÇϰí ÀÖÀ¸¸é double·Î ±×·¸Áö ¾ÊÀ¸¸é integer·Î º¯È¯ÀÌ µÈ´Ù. <BR><BR>- variable variable : º¯¼öÀÇ °ªÀÌ º¯¼öÀÇ À̸§ÀÌ µÇ´Â °ÍÀ» ¸»ÇÑ´Ù. ¿¹¸¦µé¾î $a = "hello" À϶§ $$a = "world"¶ó°í Á¤ÀÇÇϸé $hello = "world"·Î Á¤ÀǵǴ °ÍÀÌ´Ù. <BR><BR>- scope : user-defined function¿¡¼´Â local function scope°¡ Àû¿ëµÈ´Ù. Áï function ¾È¿¡¼ Á¤ÀÇµÈ º¯¼ö´Â function¾È¿¡¼¸¸ Àǹ̰¡ ÀÖ´Ù. ÁÖÀÇÇÒ Á¡Àº ¿ÜºÎ¿¡¼ Á¤ÀÇµÈ º¯¼öµµ user-defined function¾È¿¡¼´Â Àǹ̰¡ ¾ø´Ù´Â °ÍÀÌ´Ù. ¿ÜºÎ¿¡¼ Á¤ÀÇµÈ º¯¼ö¸¦ »ç¿ëÇÏ·Á¸é ÇÔ¼ö ¾È¿¡¼ global $externalVar; Çü½ÄÀ¸·Î Á¤ÀǸ¦ ÇÏ°í »ç¿ëÇϰųª $GLOBALS["externalVar"] Çü½ÄÀ¸·Î Á÷Á¢ º¯¼ö¸¦ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. <BR><BR>- static variable : local function scope¸¦ °¡ÁöÁö¸¸ scope¸¦ ¹þ¾î³ª´õ¶óµµ °ªÀÌ À¯ÁöµÇ´Â º¯¼ö¸¦ ¸»ÇÑ´Ù. <BR><BR>Array <BR><BR>- array´Â $array[] Çü½ÄÀ¸·Î »ç¿ëµÈ´Ù. <BR><BR>- scalar array : ÷ÀÚ°¡ ¼ýÀÚ·Î ÁÖ¾îÁö´Â ¹è¿ÀÌ´Ù. ¿¹¸¦ µé¸é $array[0] = 1; <BR><BR>- associative array : ÷ÀÚ°¡ ¼ýÀÚ°¡ ¾Æ´Ï¶ó ¹®ÀÚ¿·Î ÁÖ¾îÁö´Â ¹è¿ÀÌ´Ù. ¿¹¸¦ µé¸é $array["first"] = 1; <BR><BR>- ±×³É $array[]¿¡ °ªÀ» ÁöÁ¤Çϸé array¿¡ °ªÀÌ Çϳª Ãß°¡µÈ´Ù. $array[] = 1; $array[] = 2; ´Â $array[0] = 1; $array[1] = 2;¿Í °°Àº Àǹ̸¦ Áö´Ñ´Ù. <BR><BR>- array() ÇÔ¼ö¸¦ ÅëÇÏ¿© array¸¦ ¸¸µé¼öµµ ÀÖ°í, count() ÇÔ¼ö·Î elementÀÇ °¹¼ö¸¦ ¾òÀ»¼öµµ ÀÖ´Ù. next(), prev() ÇÔ¼ö³ª each() ÇÔ¼ö¸¦ ÅëÇÏ¿© elementµéÀ» ÂüÁ¶ÇÒ ¼öµµ ÀÖ´Ù. <BR><BR>External Variables (¿ÜºÎº¯¼ö) <BR><BR>- HTML form (GET/POST) : formÀ¸·Î Àü´ÞµÈ °ªÀº form¿¡¼ name field·Î ÁöÁ¤ÇÑ À̸§ÀÇ º¯¼ö·Î ÁöÁ¤ÀÌ µÈ´Ù. form¿¡¼ type = "image"ÀÎ °æ¿ì¿¡´Â ¸¶¿ì½º·Î Ŭ¸¯ÇÑ À§Ä¡°¡ name_x, name_y ÇüÅ·ΠÃß°¡·Î Àü´ÞµÈ´Ù. <BR><BR>- HTTP Cookie : browser·Î cookie¸¦ Àü´ÞÇÏ·Á¸é SetCookie(name, value, timeout) ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù. client·ÎºÎÅÍ Àü´ÞµÇ´Â cookie´Â PHP º¯¼ö·Î º¯È¯ÀÌ µÈ´Ù. <BR><BR>- Environment Variable : ȯ°æº¯¼ö ¶ÇÇÑ PHP º¯¼öó·³ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ȯ°æº¯¼ö´Â getenv()¶ó´Â ÇÔ¼ö¸¦ ÀÌ¿ëÇØ ¾òÀ» ¼ö ÀÖÀ¸¸ç putenv() ÇÔ¼ö·Î ȯ°æº¯¼ö¸¦ ÁöÁ¤ÇÒ ¼öµµ ÀÖ´Ù. <BR><BR><BR>2. Class <BR>- class keyword¸¦ »ç¿ëÇÏ¿© class¸¦ Á¤ÀÇÇϸç instance »ý¼ºÀº new operator¸¦ ÀÌ¿ëÇÑ´Ù. <BR><BR>- classÀÇ »ó¼ÓÀº extends keyword¸¦ »ç¿ëÇÑ´Ù. <BR><BR>- constructor Á¤ÀÇ´Â class¿Í °°Àº À̸§À» °®´Â »ó¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î½á ÀÌ·ç¾îÁø´Ù. constructor´Â default parameter¸¦ °¡Áú ¼ö ÀÖ´Ù. <BR><BR>¿¹) <BR><BR>class testClass { <BR>var $value; <BR>function testClass($defValue = "test") { $value = $defValue; } <BR>function doSet($setValue) { $value = $setvalue; } <BR>function doPrint() { echo $value; } <BR>} <BR>class testLineClass extends testClass { <BR>function doPrintLine() { echo("$valuen"); } <BR>} <BR><BR>$test = new testClassLine; <BR>$test->doSet("hello"); <BR>$test->doPrint(); <BR>$test->doPrintLine(); <BR>3. Expression <BR>- expressionÀ̶õ °ªÀ¸·Î ȯ»êµÇ´Â °ÍÀ» ¸»ÇÑ´Ù. <BR><BR>- assignment´Â expressionÀ̹ǷΠ$a = $b = 5; °°Àº ¹®ÀåÀ» ¾µ ¼ö ÀÖ´Ù. <BR><BR>- pre and post increment / decrement : $a++, ++$a, $a--, --$a <BR><BR>- comparison operator´Â boolean °ªÀ» °®´Â expressionÀÌ´Ù. <BR><BR>- operator¿Í assignmentÀÇ °áÇÕ : $a += 3; $b = ++$a; $c = double(--$b); $d = $c += 10; <BR><BR>- boolean : ¼ýÀÚ¿¡¼ 0Àº false, 0ÀÌ ¾Æ´Ñ°ªÀº trueÀÌ´Ù. ¹®ÀÚ¿¿¡¼ ""¿Í "0"Àº false, ³ª¸ÓÁö´Â trueÀÌ´Ù. array¿¡¼´Â element°¡ Çϳªµµ ¾øÀ¸¸é false, Çϳª¶óµµ ÀÖÀ¸¸é trueÀÌ´Ù. <BR><BR><BR>4. Statement <BR>- if ¹® : <BR><BR>if (expression) { <BR>do anything 1; <BR>} elseif (expression) { <BR>do anything 2; <BR>} else <BR>do anything 3; <BR><BR>¶Ç´Â <BR><BR>if (expression) : <BR>do anything 1; <BR>elseif (expression) : <BR>do anything 2; <BR>else : <BR>do anything 3; <BR>endif; <BR>- while ¹® : <BR><BR>while (expression) <BR>do anything; <BR><BR>¶Ç´Â <BR><BR>while (expression) : <BR>do anything; <BR>endwhile; <BR>- do...while ¹® : <BR><BR>do { <BR>do anything; <BR>} while (expression); <BR>- for ¹® : <BR><BR>for (expr1; expr2; expr3) <BR>do anything; <BR>- switch ¹® : <BR><BR>switch (expression) { <BR>case ... : <BR>do anything; <BR>break; <BR>default : <BR>do anything; <BR>} <BR>- loop¿¡¼ break¸¦ ÀÌ¿ëÇÑ Á¦¾î°¡ °¡´ÉÇÏ´Ù. <BR><BR>5. Function (ÇÔ¼ö) <BR>- ÇÔ¼ö´Â function À̶ó´Â keyword¸¦ °¡Áö°í Á¤Àǰ¡ µÇ¸ç º°µµ·Î return typeÀº ÁöÁ¤ÇÏÁö ¾Ê´Â´Ù. <BR><BR>- functionÀÇ ±âº»ÇüÀº ´ÙÀ½°ú °°´Ù. <BR><BR>function funcName($arg1, $arg2, $arg3, ..., $argn) { <BR>do anything; <BR>return $retval; <BR>} <BR>- return value´Â list¿Í object¸¦ Æ÷ÇÔÇÏ¿© ¾î¶² typeÀÌµç µÉ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¾î array¸¦ returnÇÏ·Á¸é return array(0, 1, 2); <BR><BR>- argument´Â default·Î pass by valueÀÌ´Ù. pass by reference·Î ÇÏ·Á¸é argument definition¿¡¼ º¯¼ö¸í ¾Õ¿¡ &¸¦ ºÙ¿©ÁÖ¸é µÈ´Ù (function funcName(&$arg1)). functionÀÌ pass by value·Î Á¤Àǰ¡ µÇ¾ú´õ¶óµµ ÇÔ¼ö¸¦ ºÎ¸¦¶§ argument¿¡ &¸¦ ºÙ¿©¼ ³Ñ±â¸é pass by reference°¡ µÈ´Ù (call : doFunc(&$var)). <BR><BR>- default parameter : C++¿¡¼ »ç¿ëÇÏ´Â ¹æ½ÄÀ¸·Î default parameter¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù : function funcName($var = 1) { } <BR><BR><BR>6. Operator <BR>- operatorµéÀº C¾ð¾î¿¡¼ÀÇ operator¿Í ºñ½ÁÇÏ¸ç ´ÙÀ½°ú °°Àº operatorµéÀÌ ÀÖ´Ù. <BR><BR>- arithmetic operator : +, -, *, /, % <BR>- string operator : . (concatenation) <BR>- assignment operator : = <BR>- bitwise operator : &, |, ~ <BR>- logical operator : and (&&), or (||), xor, ! <BR>- comparison operator : ==, !=, <, >, <=, >= <BR><BR><BR>7. ±×¹Û¿¡ <BR>- require : #include¿Í ¶È°°Àº Àǹ̷Π»ç¿ëµÈ´Ù. <BR><BR>- include : include ¹®ÀåÀ» ¸¸³¯¶§¸¶´Ù ÁöÁ¤ÇÑ ÆÄÀÏÀ» Æ÷ÇÔÇÑ´Ù. require´Â #include ó·³ ¹«Á¶°Ç ÆÄÀÏÀ» Æ÷ÇÔ½ÃŰÁö¸¸ include´Â loop³ª if ¹® µî¿¡¼ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸ç ÇÊ¿äÇÑ °æ¿ì¿¡¸¸ ÆÄÀÏÀ» Æ÷ÇÔÇϵµ·Ï ÇÒ ¼ö ÀÖ´Ù. <BR>
<BR><BR>1. Variable (º¯¼ö) <BR>- º¯¼ö´Â $·Î ½ÃÀÛÇÑ´Ù. <BR><BR>- º¯¼ö´Â º°µµ·Î ¼±¾ðÇÏ´Â ºÎºÐÀÌ ¾øÀ¸¸ç (typeÀ» ¹Ì¸® ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸ç) º¯¼ö typeÀº º¯¼ö°¡ »ç¿ëµÈ context¿¡ µû¶ó °áÁ¤µÈ´Ù. <BR><BR>- º¯¼öÀÇ typeÀ¸·Î´Â ±âº»ÀûÀ¸·Î integer, double, string typeÀÌ ÀÖÀ¸¸ç À̿ܿ¡ array¿Í object typeÀÌ ÀÖ´Ù. º¯¼ö typeÀº gettype(), is_long(), is_double(), is_string(), is_array(), is_object() µîÀÇ ÇÔ¼ö·Î ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù. <BR><BR>- type castingÀº C¿¡¼¿Í °°Àº Çü½ÄÀ¸·Î ÀÌ·ç¾îÁø´Ù. (int) (integer) (real) (double) (float) (string) (array) (object) µîÀÇ casting operator°¡ ÀÖ´Ù. <BR><BR>- string conversion : ¹®ÀÚ¿ÀÌ ¼ýÀÚ·Î º¯È¯µÉ ¶§¿¡ ¹®ÀÚ¿ÀÌ '.', 'e', 'E'¸¦ Æ÷ÇÔÇϰí ÀÖÀ¸¸é double·Î ±×·¸Áö ¾ÊÀ¸¸é integer·Î º¯È¯ÀÌ µÈ´Ù. <BR><BR>- variable variable : º¯¼öÀÇ °ªÀÌ º¯¼öÀÇ À̸§ÀÌ µÇ´Â °ÍÀ» ¸»ÇÑ´Ù. ¿¹¸¦µé¾î $a = "hello" À϶§ $$a = "world"¶ó°í Á¤ÀÇÇϸé $hello = "world"·Î Á¤ÀǵǴ °ÍÀÌ´Ù. <BR><BR>- scope : user-defined function¿¡¼´Â local function scope°¡ Àû¿ëµÈ´Ù. Áï function ¾È¿¡¼ Á¤ÀÇµÈ º¯¼ö´Â function¾È¿¡¼¸¸ Àǹ̰¡ ÀÖ´Ù. ÁÖÀÇÇÒ Á¡Àº ¿ÜºÎ¿¡¼ Á¤ÀÇµÈ º¯¼öµµ user-defined function¾È¿¡¼´Â Àǹ̰¡ ¾ø´Ù´Â °ÍÀÌ´Ù. ¿ÜºÎ¿¡¼ Á¤ÀÇµÈ º¯¼ö¸¦ »ç¿ëÇÏ·Á¸é ÇÔ¼ö ¾È¿¡¼ global $externalVar; Çü½ÄÀ¸·Î Á¤ÀǸ¦ ÇÏ°í »ç¿ëÇϰųª $GLOBALS["externalVar"] Çü½ÄÀ¸·Î Á÷Á¢ º¯¼ö¸¦ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù. <BR><BR>- static variable : local function scope¸¦ °¡ÁöÁö¸¸ scope¸¦ ¹þ¾î³ª´õ¶óµµ °ªÀÌ À¯ÁöµÇ´Â º¯¼ö¸¦ ¸»ÇÑ´Ù. <BR><BR>Array <BR><BR>- array´Â $array[] Çü½ÄÀ¸·Î »ç¿ëµÈ´Ù. <BR><BR>- scalar array : ÷ÀÚ°¡ ¼ýÀÚ·Î ÁÖ¾îÁö´Â ¹è¿ÀÌ´Ù. ¿¹¸¦ µé¸é $array[0] = 1; <BR><BR>- associative array : ÷ÀÚ°¡ ¼ýÀÚ°¡ ¾Æ´Ï¶ó ¹®ÀÚ¿·Î ÁÖ¾îÁö´Â ¹è¿ÀÌ´Ù. ¿¹¸¦ µé¸é $array["first"] = 1; <BR><BR>- ±×³É $array[]¿¡ °ªÀ» ÁöÁ¤Çϸé array¿¡ °ªÀÌ Çϳª Ãß°¡µÈ´Ù. $array[] = 1; $array[] = 2; ´Â $array[0] = 1; $array[1] = 2;¿Í °°Àº Àǹ̸¦ Áö´Ñ´Ù. <BR><BR>- array() ÇÔ¼ö¸¦ ÅëÇÏ¿© array¸¦ ¸¸µé¼öµµ ÀÖ°í, count() ÇÔ¼ö·Î elementÀÇ °¹¼ö¸¦ ¾òÀ»¼öµµ ÀÖ´Ù. next(), prev() ÇÔ¼ö³ª each() ÇÔ¼ö¸¦ ÅëÇÏ¿© elementµéÀ» ÂüÁ¶ÇÒ ¼öµµ ÀÖ´Ù. <BR><BR>External Variables (¿ÜºÎº¯¼ö) <BR><BR>- HTML form (GET/POST) : formÀ¸·Î Àü´ÞµÈ °ªÀº form¿¡¼ name field·Î ÁöÁ¤ÇÑ À̸§ÀÇ º¯¼ö·Î ÁöÁ¤ÀÌ µÈ´Ù. form¿¡¼ type = "image"ÀÎ °æ¿ì¿¡´Â ¸¶¿ì½º·Î Ŭ¸¯ÇÑ À§Ä¡°¡ name_x, name_y ÇüÅ·ΠÃß°¡·Î Àü´ÞµÈ´Ù. <BR><BR>- HTTP Cookie : browser·Î cookie¸¦ Àü´ÞÇÏ·Á¸é SetCookie(name, value, timeout) ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù. client·ÎºÎÅÍ Àü´ÞµÇ´Â cookie´Â PHP º¯¼ö·Î º¯È¯ÀÌ µÈ´Ù. <BR><BR>- Environment Variable : ȯ°æº¯¼ö ¶ÇÇÑ PHP º¯¼öó·³ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ȯ°æº¯¼ö´Â getenv()¶ó´Â ÇÔ¼ö¸¦ ÀÌ¿ëÇØ ¾òÀ» ¼ö ÀÖÀ¸¸ç putenv() ÇÔ¼ö·Î ȯ°æº¯¼ö¸¦ ÁöÁ¤ÇÒ ¼öµµ ÀÖ´Ù. <BR><BR><BR>2. Class <BR>- class keyword¸¦ »ç¿ëÇÏ¿© class¸¦ Á¤ÀÇÇϸç instance »ý¼ºÀº new operator¸¦ ÀÌ¿ëÇÑ´Ù. <BR><BR>- classÀÇ »ó¼ÓÀº extends keyword¸¦ »ç¿ëÇÑ´Ù. <BR><BR>- constructor Á¤ÀÇ´Â class¿Í °°Àº À̸§À» °®´Â »ó¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î½á ÀÌ·ç¾îÁø´Ù. constructor´Â default parameter¸¦ °¡Áú ¼ö ÀÖ´Ù. <BR><BR>¿¹) <BR><BR>class testClass { <BR>var $value; <BR>function testClass($defValue = "test") { $value = $defValue; } <BR>function doSet($setValue) { $value = $setvalue; } <BR>function doPrint() { echo $value; } <BR>} <BR>class testLineClass extends testClass { <BR>function doPrintLine() { echo("$valuen"); } <BR>} <BR><BR>$test = new testClassLine; <BR>$test->doSet("hello"); <BR>$test->doPrint(); <BR>$test->doPrintLine(); <BR>3. Expression <BR>- expressionÀ̶õ °ªÀ¸·Î ȯ»êµÇ´Â °ÍÀ» ¸»ÇÑ´Ù. <BR><BR>- assignment´Â expressionÀ̹ǷΠ$a = $b = 5; °°Àº ¹®ÀåÀ» ¾µ ¼ö ÀÖ´Ù. <BR><BR>- pre and post increment / decrement : $a++, ++$a, $a--, --$a <BR><BR>- comparison operator´Â boolean °ªÀ» °®´Â expressionÀÌ´Ù. <BR><BR>- operator¿Í assignmentÀÇ °áÇÕ : $a += 3; $b = ++$a; $c = double(--$b); $d = $c += 10; <BR><BR>- boolean : ¼ýÀÚ¿¡¼ 0Àº false, 0ÀÌ ¾Æ´Ñ°ªÀº trueÀÌ´Ù. ¹®ÀÚ¿¿¡¼ ""¿Í "0"Àº false, ³ª¸ÓÁö´Â trueÀÌ´Ù. array¿¡¼´Â element°¡ Çϳªµµ ¾øÀ¸¸é false, Çϳª¶óµµ ÀÖÀ¸¸é trueÀÌ´Ù. <BR><BR><BR>4. Statement <BR>- if ¹® : <BR><BR>if (expression) { <BR>do anything 1; <BR>} elseif (expression) { <BR>do anything 2; <BR>} else <BR>do anything 3; <BR><BR>¶Ç´Â <BR><BR>if (expression) : <BR>do anything 1; <BR>elseif (expression) : <BR>do anything 2; <BR>else : <BR>do anything 3; <BR>endif; <BR>- while ¹® : <BR><BR>while (expression) <BR>do anything; <BR><BR>¶Ç´Â <BR><BR>while (expression) : <BR>do anything; <BR>endwhile; <BR>- do...while ¹® : <BR><BR>do { <BR>do anything; <BR>} while (expression); <BR>- for ¹® : <BR><BR>for (expr1; expr2; expr3) <BR>do anything; <BR>- switch ¹® : <BR><BR>switch (expression) { <BR>case ... : <BR>do anything; <BR>break; <BR>default : <BR>do anything; <BR>} <BR>- loop¿¡¼ break¸¦ ÀÌ¿ëÇÑ Á¦¾î°¡ °¡´ÉÇÏ´Ù. <BR><BR>5. Function (ÇÔ¼ö) <BR>- ÇÔ¼ö´Â function À̶ó´Â keyword¸¦ °¡Áö°í Á¤Àǰ¡ µÇ¸ç º°µµ·Î return typeÀº ÁöÁ¤ÇÏÁö ¾Ê´Â´Ù. <BR><BR>- functionÀÇ ±âº»ÇüÀº ´ÙÀ½°ú °°´Ù. <BR><BR>function funcName($arg1, $arg2, $arg3, ..., $argn) { <BR>do anything; <BR>return $retval; <BR>} <BR>- return value´Â list¿Í object¸¦ Æ÷ÇÔÇÏ¿© ¾î¶² typeÀÌµç µÉ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¾î array¸¦ returnÇÏ·Á¸é return array(0, 1, 2); <BR><BR>- argument´Â default·Î pass by valueÀÌ´Ù. pass by reference·Î ÇÏ·Á¸é argument definition¿¡¼ º¯¼ö¸í ¾Õ¿¡ &¸¦ ºÙ¿©ÁÖ¸é µÈ´Ù (function funcName(&$arg1)). functionÀÌ pass by value·Î Á¤Àǰ¡ µÇ¾ú´õ¶óµµ ÇÔ¼ö¸¦ ºÎ¸¦¶§ argument¿¡ &¸¦ ºÙ¿©¼ ³Ñ±â¸é pass by reference°¡ µÈ´Ù (call : doFunc(&$var)). <BR><BR>- default parameter : C++¿¡¼ »ç¿ëÇÏ´Â ¹æ½ÄÀ¸·Î default parameter¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù : function funcName($var = 1) { } <BR><BR><BR>6. Operator <BR>- operatorµéÀº C¾ð¾î¿¡¼ÀÇ operator¿Í ºñ½ÁÇÏ¸ç ´ÙÀ½°ú °°Àº operatorµéÀÌ ÀÖ´Ù. <BR><BR>- arithmetic operator : +, -, *, /, % <BR>- string operator : . (concatenation) <BR>- assignment operator : = <BR>- bitwise operator : &, |, ~ <BR>- logical operator : and (&&), or (||), xor, ! <BR>- comparison operator : ==, !=, <, >, <=, >= <BR><BR><BR>7. ±×¹Û¿¡ <BR>- require : #include¿Í ¶È°°Àº Àǹ̷Π»ç¿ëµÈ´Ù. <BR><BR>- include : include ¹®ÀåÀ» ¸¸³¯¶§¸¶´Ù ÁöÁ¤ÇÑ ÆÄÀÏÀ» Æ÷ÇÔÇÑ´Ù. require´Â #include ó·³ ¹«Á¶°Ç ÆÄÀÏÀ» Æ÷ÇÔ½ÃŰÁö¸¸ include´Â loop³ª if ¹® µî¿¡¼ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸ç ÇÊ¿äÇÑ °æ¿ì¿¡¸¸ ÆÄÀÏÀ» Æ÷ÇÔÇϵµ·Ï ÇÒ ¼ö ÀÖ´Ù. <BR>
÷ºÎÆÄÀÏ
°ßÀû°è»êÇϱâ
ÀÛ¾÷ÀÇ·Ú
°ßÀû¹®ÀÇ
°øÁö»çÇ×