[php] ÁÖ¼®°ú °ø¹éÀ» Á¦°ÅÇÏ¿© ¹ÝȯÇÏ´Â php strip whitespace ÇÔ¼ö |
|
|
 |
10³â Àü |
string php_strip_whitespace ( string $filename ) (PHP 5)
php ÆÄÀϳ» ÁÖ¼®°ú °ø¹éÀ» Á¦°ÅÇÑ ¼Ò½º¸¦ ¹ÝȯÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù.
¿¹Á¦(ex #1
<?php
// PHP comment here
/*
* Another PHP comment
*/
echo php_strip_whitespace(__FILE__);
// Newlines are considered whitespace, and are removed too:
do_nothing();
/* °á°ú: <?php
echo php_strip_whitespace(__FILE__); do_nothing(); ?>
*/
?>
¿¹Á¦(ex #2
<?php
echo php_strip_whitespace(__FILE__);
/**
* @author Zulfugar Ismayilzadeh
* @copyright 2011
*/
function count_words($string){
$string = trim(preg_replace("/\s+/"," ",$string));
$word_array = explode(" ", $string);
$num = count($word_array);
return $num;
}
$str = "Hello fri3nd, you're looking good today!";
echo count_words($str);
/* °á°ú: <?php
echo php_strip_whitespace(__FILE__); function
count_words($string){ $string = trim(preg_replace("/\s+/"," ",
$string)); $word_array = explode(" ", $string); $num = count $word_array); return
$num; } $str = "Hello fri3nd, you're looking good today!";
echo count_words($str); ?>
*/
?>
ÁÖ¼®, °ø¹éÀ» Á¦°ÅÇÑ php ¼Ò½º¸¦ »õ·Î¿î ÆÄÀÏ¿¡ ÀÛ¼ºÇØ º¸°Ú½À´Ï´Ù. ÀÌ·¸°Ô µû·Î ÀÛ¼ºÇؼ ¹èÆ÷¸¦ ÇØµÎ¸é ÀÏ¹Ý »ç¿ëÀÚ°¡ Àб⿡ ¾î·Á¿òÀÌ ÀÖ¾î ¾à°£ÀÇ º¸¾È(?)¼ºÀÌ »ý±â°Ô µË´Ï´Ù.
¿¹Á¦(ex #3
<?php
$fp = fopen('oldfile.php', 'w+');
$tmp = php_strip_whitespace('newfile.php');
fputs($fp, $tmp);
fclose();
?>
|
|
̵̧ : 486 |
̵̧
¸ñ·Ï
|
|