FrontPage|FindPage|TitleIndex|RecentChanges|RSS Php Tips
 

PHP Programming Tips #


getcwd() ´ë½Å dirname(__FILE__)À» ÀÌ¿ëÇÑ´Ù #

apacheÀÇ ÄÄÆÄÀÏ °úÁ¤ÀÇ Â÷ÀÌ¿¡ µû¶ó, getcwd()ÀÇ ÀÀ´äÀÌ ´Ù¸¦ ¼ö ÀÖ´Ù. ³»°¡ ±â´ëÇÏ´Â °ªÀº 'ÇöÀç ½ÇÇàµÇ°í ÀÖ´Â ½ºÅ©¸³Æ® ÆÄÀÏ'À» ¸»ÇÏ´Â °ÍÀ̹ǷÎ, dirname(__FILE__)ÀÌ º¸´Ù ¸íÈ®ÇÏ´Ù.

ÇöÀç ½ÇÇàµÇ°í ÀÖ´Â phpÀÇ URL ¾ò¾î³»±â #

$_SERVER?'HTTP_HOST'·ÎºÎÅÍ biscuit.cafe24.comÀ» ¾òÀ» ¼ö ÀÖ°í, $_SERVER?'REQUEST_URI' ·ÎºÎÅÍ ³ª¸ÓÁöºÎºÐÀ» ¾ò¾î³¾ ¼ö Àִµ¥, ½ÇÁ¦·Î ÁÖ¼Òâ¿¡ ±â·ÏµÈ URI¿Í ¶È°°À¸¹Ç·Î ¹°À½Ç¥¸¦ ±âÁØÀ¸·Î Çؼ­ Àß¶ó³»¾ß ÇÑ´Ù.

$baseurl_arr = explode("?", 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$baseurl = $baseurl_arr[0];

register_globals = Off ¿¡¼­ÀÇ ÇÁ·Î±×·¡¹Ö #

¿¹Àü¿¡´Â $aa, $bb ¶ó´Â º¯¼ö°¡ ´Ù¸¥ ÆäÀÌÁö·Î Àü¼Û µÇ¸é, ±× ÆäÀÌÁö¿¡¼­µµ $aa $bb ¶ó´Â º¯¼ö·Î Á¢±ÙÀÌ °¡´ÉÇßÀ¸³ª, º¸¾ÈÀûÀÎ Ãë¾àÁ¡ÀÌ ÀÖ¾î register_globals = Off ¶ó´Â ȯ°æ º¯¼ö·Î ¼³Á¤À» Á¦ÇÑÇÏ°í ÀÖ´Ù.

µû¶ó¼­, Áö±ÝÀº ÆäÀÌÁö Àü¼Û ¹æ½Ä¿¡ µû¶ó GET ¹æ½ÄÀ¸·Î Àü¼ÛµÈ °æ¿ì $HTTP_GET_VARS?'aa' ¶Ç´Â $_GET?'aa'·Î POST ¹æ½ÄÀ¸·Î Àü¼ÛµÈ °æ¿ì $HTTP_POST_VARS?'aa' ¶Ç´Â $_POST?'aa'·Î¸¸ Á¢±ÙÀÌ °¡´É.

PHP ½´ÆÛÀü¿ªº¯¼ö µéÀÇ Á¾·ù #


ÀÔÃâ·Â¿¡¼­ÀÇ Quote ó¸® #

single quote '
double quote "
ampersand &
gt <
lt >
ÀÌ°ÍÀ» textarea·Î ¹Þ¾Æ¼­, ±×´ë·Î Àо¸é quote¸¦ ƯÀÌÇÏ°Ô Ã³¸®ÇÏ°í ÀÖÀ½À» ¾Ë ¼ö ÀÖ´Ù.
single quote \'
double quote \"
ampersand &
gt <
lt >
µû¶ó¼­, \'¸¦ '·Î \"¸¦ "·Î º¯È¯ÇØÁÖ´Â °úÁ¤ÀÌ ÇÊ¿äÇÏ´Ù.
function quote_decode($text)
{
   $trans = array("\'" => "'",  '\"' => '"');
   return strtr($text, $trans);
}

last modified 2007-01-17 18:24:28
EditText|FindPage|DeletePage|LikePages|