|
|
Ŭ¶ó¿ìµåű×
Javascript PHP ASP CSS HTML MYSQL jquery image Mobile API slide °Ô½ÃÆÇ ¸Þ´º
|
|
|
ÇöÀçÁ¢¼ÓÀÚ ¸í |
|
|
|
|
|
|
|
|
|
¼Ò½ººÐ·ù |
PHP °ÁÂ |
|
|
´Ù¿î·Îµå Ƚ¼ö |
0 ȸ |
|
|
|
°£´Ü¼³¸í |
PHP¿¡¼ ¹®ÀÚ¿À» ã´Â ÇÔ¼öµéÀÇ »ç¿ë¹ýÀÔ´Ï´Ù. |
|
|
|
|
|
PHP¿¡¼ ¹®ÀÚ¿À» °Ë»öÇϰųª ºñ±³ÇÏ´Â ÇÔ¼ö´Â ´Ù¾çÇÏ°Ô ÀÖ½À´Ï´Ù.
¿¹Àü¿¡´Â ereg(), eregi() ÇÔ¼ö¸¦ »ç¿ëÇßÀ¸³ª PHP 5.3 ¹öÀüºÎÅÍ´Â ¼º´É»óÀÇ ÀÌÀ¯·Î »èÁ¦µÇ¾úÁÒ...
À̹ø¿¡ ¾Ë¾Æº¸´Â ¹®ÀÚ¿ ÇÔ¼ö´Â
preg_match(), strpos(), strstr() ÇÔ¼öÀÔ´Ï´Ù. (´õ ¸¹Àº ÇÔ¼ö°¡ ÀÖ°ÚÁÒ? ^^)
1. preg_match() ÇÔ¼ö´Â ¹®ÀÚ¿ ¾È¿¡¼ ƯÁ¤ÇÑ ÆÐÅÏÀ» ã´Âµ¥ À¯¿ëÇÕ´Ï´Ù.
$subject = "Go To page #9";
$pattern = "/to/i";
if(preg_match($pattern, $subject, $matches))
echo "ÀÏÄ¡ÇÏ´Â ÆÐÅÏÀÌ ÀÖ½À´Ï´Ù. (".$matches[0].")";
else
echo "ÀÏÄ¡ÇÏ´Â ÆÐÅÏÀÌ ¾ø½À´Ï´Ù.";
ÆÐÅÏÀÓÀ» ¾Ë¸®±â À§ÇØ ¾Õ°ú µÚ¸¦ ½½·¯½¬(/)·Î ¹¾îÁà¾ß Çϸç
¸¶Áö¸· ½½·¯½¬ µÚ¿¡ ¿É¼ÇÀ» ÁÜÀ¸·Î½á ´Ù¾çÇÑ Ç¥ÇöÀ» ÇÒ ¼ö ÀÖ½À´Ï´Ù.
preg_match()ÀÇ ¿É¼ÇÀº Á÷Á¢ ã¾Æº¸½Ã±æ...¿É¼Ç ÀÚü°¡ ´Ù¾çÇؼ
¹«±Ã¹«ÁøÇÑ ÆÐÅÏÀ» °Ë»öÇÒ ¼ö Àְڳ׿ä. ^^
2. strpos() ÇÔ¼ö´Â ¹®ÀÚ¿ÀÌ Ã³À½ ³ªÅ¸³ª´Â À§Ä¡¸¦ ã´Â ÇÔ¼öÀÔ´Ï´Ù.
$mystring = ``abc``;
$findme = ``a``;
$pos = strpos($mystring, $findme);
if ($pos === false) {
echo "``$findme`` ¹®ÀÚ¿À» ``$mystring`` ¹®ÀÚ¿¿¡¼ ãÁö ¸øÇß½À´Ï´Ù.";
} else {
echo "``$findme`` ¹®ÀÚ¿À» ``$mystring`` ¹®ÀÚ¿¿¡¼ ã¾Ò½À´Ï´Ù.";
echo "À§Ä¡ $pos¿¡ Á¸ÀçÇÕ´Ï´Ù.";
}
strpos()´Â booleanÀ» ¹Þ¾Æ¿Ã ¶§
ÂüÀ̸é ===, °ÅÁþÀ̸é !==¸¦ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù.
¸î¹ø°ºÎÅÍ ½ÃÀÛÇÒ °ÍÀÎÁö¸¦ Á¤Çؼ ÇØ´ç ¹®ÀÚ¿À» ã¾Æ³»°Ô ÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
3. strstr() ÇÔ¼ö´Â °Ë»öÇÏ´Â ¹®ÀÚ¿ ³»¿¡¼ ÀÔ·ÂÇÑ ¹®ÀÚ¿ÀÌ ÀÖ´ÂÁö °Ë»öÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù.
$a = "http://www.happycgi.com";
$strstr = strstr($a, ``happy``);
if($strstr)
{
echo "ÀÏÄ¡ÇÏ´Â°Ô ÀÖ±º¿ä!";
}
else
{
echo "ÀÏÄ¡ÇÏ´Â°Ô ¾ø¾î¿ä ¤Ð¤Ð";
}
º¸Åë strstr() ÇÔ¼ö´Â ã´Â ¹®ÀÚ¿¿¡¼ ÀÔ·ÂµÈ ¹®ÀÚ¿ºÎÅÍ °¡Á®¿À´Â Çü½ÄÀ¸·Î »ç¿ëÇÏÁö¸¸
À§ ¼Ò½ºÃ³·³ ã´Â ¹®ÀÚ¿ ¾È¿¡ ÀÔ·ÂµÈ ¹®ÀÚ¿ÀÌ Æ÷ÇԵǾî ÀÖ´ÂÁö °Ë»çÇÒ¶§µµ À¯¿ëÇÏ´ä´Ï´Ù.
|
|
³×ƼÁð ÀÇ°ß ÀÌ¿ëÇϽŠÀÚ·áÀÇ Èı⸦ ÀÚÀ¯·Ó°Ô ÀÛ¼ºÇϼ¼¿ä. (»ó¾÷ÀûÀÎ ±¤°í ¹× µµ¹è¼º ±Û µîÀº »çÀüÅ뺸¾øÀÌ »èÁ¦µÉ ¼ö ÀÖ½À´Ï´Ù.) |
|