본문 바로가기

반응형

Web Programings/PHP

(8)
[PHP] HTML 작업시 PHP의 에러 출력하기 HTML에서 작업시 사소한 에러는 출력하지 않는 경우가 있다. PHP 작업시 아래 코드를 넣어주면 모든 에러를 브라우저를 통해 볼 수 있다. ini_set("display_errors", 1);
[PHP] PHP로 URL의 결과 값 가져오기 file_get_contents() 함수를 이용하면 URL의 내용을 가져 올 수 있다. file_get_contents("http://localhost/search?word=감자"); 이처럼 URL에 인자를 넣어서 보낼 수도 있으며, 결과값 또한 가져 올 수 있다. 문제1 : 인자에 스페이스가 들어간 경우! 해결 : 인자값을 urlencode해서 보내버린다. $word = encode($word) $url="http://rkawk.co.kr/search?=".$word; // 완성된 url
[PHP] php끼리 post 송수신 하기 "value");$res = post_request($url, $value);?>
[php] URL 링크 제공하기 $file = "file.csv"; if(($fp=@fopen($file,"rb"))) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 5'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Len..
[PHP] 함수 목록 및 기능 file_get_contents - 파일을 통해 스트링 형태로 가져온다. URL을 통해 가져오기도 가능! file_put_contents - 스트링 형태의 값을 파일로 저장 shell_exec - 리눅스 명령어를 실행
[PHP] PHP에서 정규식 이메일의 아이디와 도메인 분류 $email = "rkawk@daum.net"; preg_match('/(^.{0,})@/', $email, $matches1); preg_match('/@(.{0,})/', $email, $matches2); echo $matches1[1]; // @의 앞부분 출력 echo $matches2[1]; // @의 뒷부분 출력 매치된 값을 치환시 나오게 $keyword = "검색!" $keyword = ereg_replace("([!])", "\\1", $keyword);
[PHP] HTML 태그 속성에 hidden 값 줄때 무언가를 선택했을때 숨기기를 원할경우 function self(val){ if(val == "self"){ document.form명.ID/NAME명.hidden=true; } } =======================================================
[PHP] 자기 페이지 출력하기 echo $_SERVER[PHP_SELF];

반응형