°øÂ¥¸ÇÀÇ Ãʺ¸ÅÂ±× Æ÷·³ Ä¿¹Â´ÏƼ^^
 ºñ°ø°³ ¸Þ½ÃÁö¸¦ È®ÀÎÇÏ·Á¸é ·Î±×ÀÎÇϽʽÿÀ.ºñ°ø°³ ¸Þ½ÃÁö¸¦ È®ÀÎÇÏ·Á¸é ·Î±×ÀÎÇϽʽÿÀ.   ·Î±×Àηα×ÀΠ HomeHome 
PHP3 ¹®¹ý ±âÃÊ

 
±Û ¾²±â   ´äº¯ ´Þ±â    °øÂ¥¸ÇÀÇ Ãʺ¸ÅÂ±× Æ÷·³ Ä¿¹Â´ÏƼ^^ °Ô½ÃÆÇ À妽º -> PHP ±âº» ¹®¹ý
ÀÌÀü ÁÖÁ¦ º¸±â :: ´ÙÀ½ ÁÖÁ¦ º¸±â  
±Û¾´ÀÌ ¸Þ½ÃÁö
totosoro
¿î¿µÀÚ


°¡ÀÔ: 2004³â 5¿ù 5ÀÏ
°Ô½Ã¹°: 50

¿Ã¸®±â¿Ã·ÁÁü: 2004-05-17 ¿ù¿äÀÏ 4:31 am    ÁÖÁ¦: PHP3 ¹®¹ý ±âÃÊ Àοë°ú ÇÔ²² ´äº¯

1. Variable (º¯¼ö)
- º¯¼ö´Â $·Î ½ÃÀÛÇÑ´Ù.

- º¯¼ö´Â º°µµ·Î ¼±¾ðÇÏ´Â ºÎºÐÀÌ ¾øÀ¸¸ç (typeÀ» ¹Ì¸® ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸ç) º¯¼ö typeÀº º¯¼ö°¡ »ç¿ëµÈ context¿¡ µû¶ó °áÁ¤µÈ´Ù.

- º¯¼öÀÇ typeÀ¸·Î´Â ±âº»ÀûÀ¸·Î integer, double, string typeÀÌ ÀÖÀ¸¸ç ÀÌ¿Ü¿¡ array¿Í object typeÀÌ ÀÖ´Ù. º¯¼ö typeÀº gettype(), is_long(), is_double(), is_string(), is_array(), is_object() µîÀÇ ÇÔ¼ö·Î ¾Ë¾Æ³¾ ¼ö ÀÖ´Ù.

- type castingÀº C¿¡¼­¿Í °°Àº Çü½ÄÀ¸·Î ÀÌ·ç¾îÁø´Ù.
(int) (integer) (real) (double) (float) (string) (array) (object) µîÀÇ casting operator°¡ ÀÖ´Ù.

- string conversion : ¹®ÀÚ¿­ÀÌ ¼ýÀÚ·Î º¯È¯µÉ ¶§¿¡ ¹®ÀÚ¿­ÀÌ '.', 'e', 'E'¸¦ Æ÷ÇÔÇÏ°í ÀÖÀ¸¸é double·Î ±×·¸Áö ¾ÊÀ¸¸é integer·Î º¯È¯ÀÌ µÈ´Ù.

- variable variable : º¯¼öÀÇ °ªÀÌ º¯¼öÀÇ À̸§ÀÌ µÇ´Â °ÍÀ» ¸»ÇÑ´Ù.
¿¹¸¦µé¾î $a = "hello" À϶§ $$a = "world"¶ó°í Á¤ÀÇÇϸé $hello = "world"·Î Á¤ÀǵǴ °ÍÀÌ´Ù.

- scope : user-defined function¿¡¼­´Â local function scope°¡ Àû¿ëµÈ´Ù.
Áï function ¾È¿¡¼­ Á¤ÀÇµÈ º¯¼ö´Â function¾È¿¡¼­¸¸ Àǹ̰¡ ÀÖ´Ù.
ÁÖÀÇÇÒ Á¡Àº ¿ÜºÎ¿¡¼­ Á¤ÀÇµÈ º¯¼öµµ user-defined function¾È¿¡¼­´Â Àǹ̰¡ ¾ø´Ù´Â °ÍÀÌ´Ù.
¿ÜºÎ¿¡¼­ Á¤ÀÇµÈ º¯¼ö¸¦ »ç¿ëÇÏ·Á¸é ÇÔ¼ö ¾È¿¡¼­ global $externalVar; Çü½ÄÀ¸·Î Á¤ÀǸ¦ ÇÏ°í »ç¿ëÇϰųª $GLOBALS["externalVar"] Çü½ÄÀ¸·Î Á÷Á¢ º¯¼ö¸¦ »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

- static variable : local function scope¸¦ °¡ÁöÁö¸¸ scope¸¦ ¹þ¾î³ª´õ¶óµµ °ªÀÌ À¯ÁöµÇ´Â º¯¼ö¸¦ ¸»ÇÑ´Ù.

Array

- array´Â $array[] Çü½ÄÀ¸·Î »ç¿ëµÈ´Ù.

- scalar array : ÷ÀÚ°¡ ¼ýÀÚ·Î ÁÖ¾îÁö´Â ¹è¿­ÀÌ´Ù. ¿¹¸¦ µé¸é $array[0] = 1;

- associative array : ÷ÀÚ°¡ ¼ýÀÚ°¡ ¾Æ´Ï¶ó ¹®ÀÚ¿­·Î ÁÖ¾îÁö´Â ¹è¿­ÀÌ´Ù.
¿¹¸¦ µé¸é $array["first"] = 1;

- ±×³É $array[]¿¡ °ªÀ» ÁöÁ¤Çϸé array¿¡ °ªÀÌ Çϳª Ãß°¡µÈ´Ù.
$array[] = 1; $array[] = 2; ´Â $array[0] = 1; $array[1] = 2;¿Í °°Àº Àǹ̸¦ Áö´Ñ´Ù.

- array() ÇÔ¼ö¸¦ ÅëÇÏ¿© array¸¦ ¸¸µé¼öµµ ÀÖ°í, count() ÇÔ¼ö·Î elementÀÇ °¹¼ö¸¦ ¾òÀ»¼öµµ ÀÖ´Ù.
next(), prev() ÇÔ¼ö³ª each() ÇÔ¼ö¸¦ ÅëÇÏ¿© elementµéÀ» ÂüÁ¶ÇÒ ¼öµµ ÀÖ´Ù.

External Variables (¿ÜºÎº¯¼ö)

- HTML form (GET/POST) : formÀ¸·Î Àü´ÞµÈ °ªÀº form¿¡¼­ name field·Î ÁöÁ¤ÇÑ À̸§ÀÇ º¯¼ö·Î ÁöÁ¤ÀÌ µÈ´Ù.
form¿¡¼­ type = "image"ÀÎ °æ¿ì¿¡´Â ¸¶¿ì½º·Î Ŭ¸¯ÇÑ À§Ä¡°¡ name_x, name_y ÇüÅ·ΠÃß°¡·Î Àü´ÞµÈ´Ù.

- HTTP Cookie : browser·Î cookie¸¦ Àü´ÞÇÏ·Á¸é SetCookie(name, value, timeout) ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù.
client·ÎºÎÅÍ Àü´ÞµÇ´Â cookie´Â PHP º¯¼ö·Î º¯È¯ÀÌ µÈ´Ù.

- Environment Variable : ȯ°æº¯¼ö ¶ÇÇÑ PHP º¯¼öó·³ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
ȯ°æ º¯¼ö´Â getenv()¶ó´Â ÇÔ¼ö¸¦ ÀÌ¿ëÇØ ¾òÀ» ¼ö ÀÖÀ¸¸ç putenv() ÇÔ¼ö·Î ȯ°æ º¯¼ö¸¦ ÁöÁ¤ÇÒ ¼öµµ ÀÖ´Ù.


2. Class
- class keyword¸¦ »ç¿ëÇÏ¿© class¸¦ Á¤ÀÇÇϸç instance »ý¼ºÀº new operator¸¦ ÀÌ¿ëÇÑ´Ù.

- classÀÇ »ó¼ÓÀº extends keyword¸¦ »ç¿ëÇÑ´Ù.

- constructor Á¤ÀÇ´Â class¿Í °°Àº À̸§À» °®´Â »ó¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î½á ÀÌ·ç¾îÁø´Ù.
constructor´Â default parameter¸¦ °¡Áú ¼ö ÀÖ´Ù.

¿¹)

class testClass {
var $value;
function testClass($defValue = "test") { $value = $defValue; }
function doSet($setValue) { $value = $setvalue; }
function doPrint() { echo $value; }
}
class testLineClass extends testClass {
function doPrintLine() { echo("$valuen"); }
}

$test = new testClassLine;
$test->doSet("hello");
$test->doPrint();
$test->doPrintLine();
3. Expression
- expressionÀ̶õ °ªÀ¸·Î ȯ»êµÇ´Â °ÍÀ» ¸»ÇÑ´Ù.

- assignment´Â expressionÀ̹ǷΠ$a = $b = 5; °°Àº ¹®ÀåÀ» ¾µ ¼ö ÀÖ´Ù.

- pre and post increment / decrement : $a++, ++$a, $a--, --$a

- comparison operator´Â boolean °ªÀ» °®´Â expressionÀÌ´Ù.

- operator¿Í assignmentÀÇ °áÇÕ : $a += 3; $b = ++$a; $c = double(--$b); $d = $c += 10;

- boolean : ¼ýÀÚ¿¡¼­ 0Àº false, 0ÀÌ ¾Æ´Ñ°ªÀº trueÀÌ´Ù.
¹®ÀÚ¿­¿¡¼­ ""¿Í "0"Àº false, ³ª¸ÓÁö´Â trueÀÌ´Ù. array¿¡¼­´Â element°¡ Çϳªµµ ¾øÀ¸¸é false, Çϳª¶óµµ ÀÖÀ¸¸é trueÀÌ´Ù.


4. Statement
- if ¹® :

if (expression) {
do anything 1;
} elseif (expression) {
do anything 2;
} else
do anything 3;

¶Ç´Â

if (expression) :
do anything 1;
elseif (expression) :
do anything 2;
else :
do anything 3;
endif;
- while ¹® :

while (expression)
do anything;

¶Ç´Â

while (expression) :
do anything;
endwhile;
- do...while ¹® :

do {
do anything;
} while (expression);
- for ¹® :

for (expr1; expr2; expr3)
do anything;
- switch ¹® :

switch (expression) {
case ... :
do anything;
break;
default :
do anything;
}
- loop¿¡¼­ break¸¦ ÀÌ¿ëÇÑ Á¦¾î°¡ °¡´ÉÇÏ´Ù.

5. Function (ÇÔ¼ö)
- ÇÔ¼ö´Â function À̶ó´Â keyword¸¦ °¡Áö°í Á¤ÀÇ°¡ µÇ¸ç º°µµ·Î return typeÀº ÁöÁ¤ÇÏÁö ¾Ê´Â´Ù.

- functionÀÇ ±âº»ÇüÀº ´ÙÀ½°ú °°´Ù.

function funcName($arg1, $arg2, $arg3, ..., $argn) {
do anything;
return $retval;
}
- return value´Â list¿Í object¸¦ Æ÷ÇÔÇÏ¿© ¾î¶² typeÀÌµç µÉ ¼ö ÀÖ´Ù.
¿¹¸¦ µé¾î array¸¦ returnÇÏ·Á¸é return array(0, 1, 2);

- argument´Â default·Î pass by valueÀÌ´Ù. pass by reference·Î ÇÏ·Á¸é
argument definition¿¡¼­ º¯¼ö¸í ¾Õ¿¡ &¸¦ ºÙ¿©ÁÖ¸é µÈ´Ù. (function funcName(&$arg1))
functionÀÌ pass by value·Î Á¤ÀÇ°¡ µÇ¾ú´õ¶óµµ ÇÔ¼ö¸¦ ºÎ¸¦¶§ argument¿¡ &¸¦ ºÙ¿©¼­ ³Ñ±â¸é pass by reference°¡ µÈ´Ù. (call : doFunc(&$var))

- default parameter : C++¿¡¼­ »ç¿ëÇÏ´Â ¹æ½ÄÀ¸·Î default parameter¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù.: function funcName($var = 1) { }


6. Operator
- operatorµéÀº C¾ð¾î¿¡¼­ÀÇ operator¿Í ºñ½ÁÇÏ¸ç ´ÙÀ½°ú °°Àº operatorµéÀÌ ÀÖ´Ù.

- arithmetic operator : +, -, *, /, %
- string operator : . (concatenation)
- assignment operator : =
- bitwise operator : &, |, ~
- logical operator : and (&&), or (||), xor, !
- comparison operator : ==, !=, <, >, <=, >=


7. ±×¹Û¿¡
- require : #include¿Í ¶È°°Àº Àǹ̷Π»ç¿ëµÈ´Ù.

- include : include ¹®ÀåÀ» ¸¸³¯¶§¸¶´Ù ÁöÁ¤ÇÑ ÆÄÀÏÀ» Æ÷ÇÔÇÑ´Ù.
require´Â #include ó·³ ¹«Á¶°Ç ÆÄÀÏÀ» Æ÷ÇÔ½ÃÅ°Áö¸¸ include´Â loop³ª if ¹® µî¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸ç ÇÊ¿äÇÑ °æ¿ì¿¡¸¸ ÆÄÀÏÀ» Æ÷ÇÔÇϵµ·Ï ÇÒ ¼ö ÀÖ´Ù.
À§·Î
»ç¿ëÀÚ Á¤º¸ º¸±â ºñ¹Ð ¸Þ½ÃÁö º¸³»±â À̸ÞÀÏ º¸³»±â
ÀÌÀü ±Û Ç¥½Ã:   
±Û ¾²±â   ´äº¯ ´Þ±â    °øÂ¥¸ÇÀÇ Ãʺ¸ÅÂ±× Æ÷·³ Ä¿¹Â´ÏƼ^^ °Ô½ÃÆÇ À妽º -> PHP ±âº» ¹®¹ý ½Ã°£´ë: GMT + 9 ½Ã°£(Çѱ¹)
ÆäÀÌÁö 1 Áß 1

 
°Ç³Ê ¶Ù±â:  
»õ·Î¿î ÁÖÁ¦¸¦ ¿Ã¸± ¼ö ¾ø½À´Ï´Ù.
´ä±ÛÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù.
ÁÖÁ¦¸¦ ¼öÁ¤ÇÒ ¼ö ¾ø½À´Ï´Ù.
¿Ã¸° ±ÛÀ» »èÁ¦ÇÒ ¼ö ¾ø½À´Ï´Ù.
ÅõÇ¥¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.
ÆÄÀÏ Ã·ºÎ¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.
ÆÄÀÏ ´Ù¿î·Îµå ÇÒ ¼ö ÀÖ½À´Ï´Ù.


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group / Designed by °øÂ¥¸Ç