PHP_EOL (string)
The correct 'End Of Line' symbol for this platform. Available since PHP 4.3.10 and PHP 5.0.2PHP의 내장 상수 PHP_EOL는 줄바꿈을 뜻한다.
echo '테스트', PHP_EOL;
해보면 <br>이 아닌 실제로 줄바꿈을 해준다
예전에 많이들 사용한 \n 이런거
PHP_EOL (string)
The correct 'End Of Line' symbol for this platform. Available since PHP 4.3.10 and PHP 5.0.2(PHP 4 >= 4.0.1, PHP 5)
str_pad — 문자열을 지정한 길이가 되도록 다른 문자열로 채웁니다
string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] )
<?php
$input = "Alien";
echo str_pad($input, 10); // "Alien "을 생성.
echo str_pad($input, 10, "-=", STR_PAD_LEFT); // "-=-=-Alien"을 생성.
echo str_pad($input, 10, "_", STR_PAD_BOTH); // "__Alien___"을 생성.
echo str_pad($input, 6 , "___"); // "Alien_"을 생성.
?>
(PHP 4 >= 4.0.5, PHP 5)
iconv — Convert string to requested character encoding
string iconv ( string $in_charset , string $out_charset , string $str )
<?php
$text = "안녕";
echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "EUC-KR//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE : ', iconv("UTF-8", "EUC-KR//IGNORE", $text), PHP_EOL;
echo 'Plain : ', iconv("UTF-8", "EUC-KR", $text), PHP_EOL;
echo 'Plain : ', iconv("EUC-KR", "UTF-8", $text), PHP_EOL;
?>
* notice에러 방지
$ret = $arr[var];
-> $ret = $arr['var'];
* notice에러 방지
if ($_POST['var'])
-> if (isset($_POST['var']))
* 남용하면 이해할수 없는 코드가 됨
isset($_POST['var'])? $_POST['var']:NULL;
-> 삼항연산자는 남용하지 않는다.
* 무한루프 방지
for($i=0; $i<$max; $i++) {
-> for($i=0, $max = count($loop); $i<$max; $i++) {
* 메모리 절약
$msg = '안녕하세요';
echo $msg;
-> echo '안녕하세요';
* 에러 방지
echo "안녕 $msg";
-> echo '안녕 '.$msg;
foreach가 빠르다
explode가 빠르다
모든 변수는 선언하지 않은채 사용하면 notice에러가 발생한다.
$("#id",opener.document).text("aa");
$("#id",parent.document).text("aa");
; This is a sample configuration file
; Comments start with ';', as in php.ini
[first_section]
one = 1
five = 5
animal = BIRD
[second_section]
path = "/usr/local/bin"
URL = "http://www.example.com/~username"
[third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"
사용방법은
<?php
$ini_array = parse_ini_file("sample.ini", true);
echo $ini_array['first_section']['one'];
?>
;<? /*
; This is a sample configuration file
; Comments start with ';', as in php.ini
[first_section]
one = 1
five = 5
animal = BIRD
[second_section]
path = "/usr/local/bin"
URL = "http://www.example.com/~username"
[third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"
;*/?>
잘돌아가던게 php 5.4로 업그레이드후 오류가 뜬다
2013/06/09 12:46:16 [error] 2952#0: *11681 FastCGI sent in stderr: "PHP message: PHP Fatal error:
Call-time pass-by-reference has been removed in /home/miyu/html/zboard/zboard.php on line 197"
while reading response header from upstream
&$error 와 같이 reference 처리된것은 모두 에러처리 되고 프로그램이 중단된다.
$error 와 같이 모든 코드를 교체해야한다.
예전에는 php.ini에서 allow_call_time_pass_reference = On으로 처리했지만
5.4부터는 사라졌다.
더불어 globals_register와 magic_quotes도 사라졌다.
The ini option allow_call_time_pass_reference was removed
Register globals, magic quotes and safe mode were removed



한 편의점 주인이 본사와 갈등을 겪다 자살을 기도한 사건 보도해 드렸습니다. 그런데 편의점 CU 측이 책임을 면하려고 고인의 사망 진단서에 손을 댄 사실이 뒤늦게 밝혀졌습니다. 수면 유도제 중독이라는 문구를 삭제했습니다.
.........