[font 태그 사용하기]
[예 문] post 입력양식
파일명: form_post.html
<html>
<body>
<form method=post action="http://localhost/form_insert.php">
이 름: <input type=text name = name><p>
내 용: <input type=text name = comment><p>
<input type=submit value="전 송">
<input type=reset value="취 소">
</form>
</body></html>
[예 문] 입력자료 처리 프로그램
파일명: form_insert.php
<?
echo "이 름 : $name <p>";
echo "내 용 : $comment";
?>
[예 문] get 입력양식
파일명: form_get.html
<html>
<body>
<form method=get action="http://localhost/form_insert.php">
이 름: <input type=text name = name><p>
내 용: <input type=text name = comment><p>
<input type=submit value="전 송">
<input type=reset value="취 소">
</form>
</body></html>
[변수 값 전달하기]
+-------------[형 식]-----------------------+
| 도메인 주소 또는 웹 문서 ? 변수=값 |
+-------------------------------------------+
[예 문]
파일명: trans.php
<?
echo (“<a href=trans1.php?kor=90&eng=80> 더하기 </a>”);
?>
파일명: trans1.php
<?
$tot = $kor + $eng ;
echo “$kor 와 $eng 의 덧셈 결과는 $tot 이다”;
?>
[Date() 사용하기]
[예 문]
파일명: date.php
<?
$a = date(“Y-m-d”); // 2002-01-20
$b = date(“H-i-s”); // 시-분-초
$c = date(“l”); // 요일
echo (“$a <p>”);
echo (“$b <p>”);
echo $c;
?>
[접속자 브라우저정보 보기]
[예 문]
파일명: browser.php
<?
$browser = getenv(“HTTP_USER_AGENT”);
echo $browser;
?>
+-----------------------------------------------+
| Mozilla4.61[ko] [X11;Linux2.2.12-20kr2 i686) |
+-----------------------------------------------+
[접속자 ip 주소 알기]
[예 문]
파일명: ip_ad.html
<?
$ipaddress = getenv(“REMOTE_ADDR”);
echo “당신의 ip 주소는 $ipaddress 이다”;
?>
+-----------------------------------------------+
| 당신의 ip 주소는 129 0 0 0 이다 |
+-----------------------------------------------+
[Select 상자에서 주소를 선택하여 이동시키기]
[예 문]
파일명: select.html
<html><body>
<form method="post" action="http://localhost/redirect.php">
<select name="location" size=1>
<option value="http://kr.yahoo.com"> 야후 </option>
<option value="http://www.naver.com"> 네이버 </option>
<option value="http://www.empas.com"> 엠파스 </option>
</select> <input type="submit" value="GOGO">
</form>
</body>
</html>
파일명: redirect.php
<?
header("Location: $location");
exit;
?>
[Include() 사용하기]
프로그램 개발 시 일정한 크기로 프로그램을 나누어 팀 별로 개발한 조
각 프로그램을 모듈이라 하며, 이들을 하나로 합칠 경우 유용한 함수.
[예 문]
파일명: top.php
<?
function bluefont($col, $size, $str) {
echo("<font color=$col size=$size> $str </font>");
}
?>
파일명: include.php
<?
include "top.php" ;
bluefont("blue", 6 , "지금은 include 함수 실습중!!1");
?>
[PHP.ini 파일 위치 알기 / 환경 설정 및 세팅 보기]
[예 문]
파일명: getphp.php
<?
print get_cfg_var("cfg_file_path");
phpinfo();
?>
[배열 정렬하기 : sort.php]
<?
$a[0]=2; $a[1]=1; $a[2]=3;
sort($a); $i =0 ;
while($i < 3) {
echo "$a[$i] <br>";
$i ++; }
?>
[PHP 소스 보기 : show.php ]
<?
Show_source("sort.php");
?>
[쿠키 사용하기]
쿠키란 웹 서버가 사용자 브라우저에 사용자의 정보를 저장하는 기능
+-----------[형 식]-----------+
| setcookie(쿠키명, 쿠키값) |
+-----------------------------+
[예 문]
파일명: cookie1.php
<?
SetCookie ("cookiename" , "cookie_test");
echo "welcome to my server!!";
?>
파일명: cookie2.php
<?
echo "쿠키값 : $cookiename";
?>
[세션 사용하기]
세션은 사용자 정보를 서버에 저장하고, 사용자 브라우저에 쿠키로 저
장하는 기능
[예 문]
파일명: session1.php
<?
session_start(); // 세션을 사용하기 위한 함수
$my_session= "홍길동";
session_register("my_session”); // 세션을 등록하는 함수
print "세션이 등록되었습니다!!";
?>
※ 만약 session1.php 프로그램을 실행하는 도중에 오류가 나오면 c:\tmp 디렉토리가
없는 경우 이므로 c:\tmp 폴더를 만드신 다음 프로그램을 다시 시작해 보세요. (세션
정보는 접속자의 하드디스크(c:\tmp) 위치에 암호화 되어 저장 됩니다.)
파일명: session2.php
<?
Session_start();
print "등록된 세션 값은: $my_session 이다";
?>
[ASCII 코드값 알아보기]
ASCII 코드값은 인간어를 컴퓨터가 이해할 수 있는 기계어이다.
[예 문]
파일명: ascii.php
<?
echo "A 부터 Z까지 출력하기 <P>";
for($i = 65 ; $i < 91; $i++) {
echo (chr($i));
}
echo "<p>";
echo "a 부터 z까지 출력하기 <P>";
for($i = 97 ; $i < 123; $i++) {
echo (chr($i));
}
?>
[오늘의 TIP 만들기]
사이트에 접속할 때마다 서로 다른 TIP을 보여 주는 예문.
파일명: tip.php
<html><body>
<table width=500 border=1>
<tr> <td bgcolor=navy> <font size=6 color=white> Today’s Tip & Skill </font>
</td></tr>
<tr> <td> <font size=2>
<?
srand((double)microtime() * 1000000); // 난수 함수를 사용하기 위한 선언문
$tiplist = file("php.txt"); // 텍스트 파일(php.txt)을 열어 행 단위로 tiplist 배열에 저장
$ntips = sizeof($tiplist); // 텍스트 파일의 행수를 구함
$rtip = rand(0,($ntips - 1)); // 텍스트 파일의 행수 만큼 난수 정수(0~3)발생
$tip = $tiplist[$rtip]; // 구해진 난수 정수를 텍스트 파일이 저장된 배열의 첨자로 사용
echo $tip; // 해당 배열의 첨자에 해당되는 1행의 내용을 출력함.
?>
</font></td></tr>
</table></body></html>
+-------------파일명 : php.txt-----------------+
| mysql은 웹 서버에서 db를 구축하는 프로그램. |
| php 언어는 웹 서버측 스크립트 언어 이다. |
| apache는 웹 서버를 구축하는 프로그램이다. |
| LINUX는 네트워크를 지원하는 운영체제이다. |
+----------------------------------------------+<
게시글 목록
| 번호 | 제목 |
|---|---|
| 27980 | |
| 7164 | |
| 31729 | |
| 31726 | |
| 31725 | |
| 31720 | |
| 31711 | |
| 7159 | |
| 27974 | |
| 19734 | |
| 19730 | |
| 19729 |
PHP
[알고리즘] 배열 역순
|
| 27969 | |
| 7142 | |
| 19728 |
jQuery
remove()를 이용하여 엘리먼트 삭제하기
|
| 19725 | |
| 7130 | |
| 19722 |
jQuery
동일 엘리먼트 순번 알아내기
2
|
| 19719 | |
| 7124 | |
| 19718 | |
| 19717 | |
| 19716 |
jQuery
position() 메서드 객체에 대한 좌표값
|
| 19715 | |
| 7122 | |
| 30959 | |
| 19714 | |
| 31710 |
jQuery Mobile
jQuery Mobile 강좌 19. Select Menus
|
| 31709 |
jQuery Mobile
jQuery Mobile 강좌 18. Text Inputs
|
| 19713 | |
| 7117 | |
| 19712 | |
| 7111 | |
| 31708 |
jQuery Mobile
jQuery Mobile 강좌 17. Form Basic
|
| 31707 |
jQuery Mobile
jQuery Mobile 강좌 16. Filters
|
| 19710 | |
| 31706 |
jQuery Mobile
jQuery Mobile 강좌 15. List Content
|
| 31705 |
jQuery Mobile
jQuery Mobile 강좌 14. List Views
|
| 31704 |
jQuery Mobile
jQuery Mobile 강좌 13. Layout Grids
|
| 19709 | |
| 19707 | |
| 31703 |
jQuery Mobile
jQuery Mobile 강좌 12. Tables
|
| 19706 |
jQuery
class가 있는지 없는지 체크하기
|
| 31702 |
jQuery Mobile
jQuery Mobile 강좌 11. Collapsibles
|
| 19705 |
PHP
배열에서 중복 값 없애기
|
| 31701 |
jQuery Mobile
jQuery Mobile 강좌 10. Panels
|
| 19704 | |
| 31700 |
jQuery Mobile
jQuery Mobile 강좌 9. Navigation Bars
|
| 31699 |
jQuery Mobile
jQuery Mobile 강좌 8. Toolbars
|
| 31698 |
jQuery Mobile
jQuery Mobile 강좌 7. Popups
|
| 7107 | |
| 19703 |
JavaScript
str_pad 자릿수만큼 특정문자로 채우기
|
| 31697 |
jQuery Mobile
jQuery Mobile 강좌 6. Icons
|
| 31696 |
jQuery Mobile
jQuery Mobile 강좌 5. Buttons
|
| 19702 | |
| 19701 | |
| 31695 |
jQuery Mobile
jQuery Mobile 강좌 4. Transitions
|
| 27965 | |
| 31694 |
jQuery Mobile
jQuery Mobile 강좌 3. Pages
|
| 19700 | |
| 31693 |
jQuery Mobile
jQuery Mobile 강좌 2. Install
|
| 19699 | |
| 31692 |
jQuery Mobile
jQuery Mobile 강좌 1. Introduction
|
| 31691 |
jQuery Mobile
jQuery Mobile 강좌 0.home
|
| 19698 | |
| 19697 | |
| 19696 |
jQuery
마우스 오버 위치에 따라 툴팁 생성 및 자동 이동
|
| 19694 | |
| 19693 |
jQuery
제이쿼리 동적으로 생성된 객체에 이벤트 생성하기
|
| 19692 | |
| 19691 | |
| 19690 |
JavaScript
shuffle 배열섞기
|
| 19689 |
jQuery
제이쿼리 모음 사이트
|
| 19688 |
PHP
1원팁] IP 대역 비교
|
| 19687 | |
| 7105 | |
| 30955 | |
| 7100 | |
| 19681 |
PHP
input 쉽게 관리하기
5
|
| 7097 | |
| 19678 |
JavaScript
서버시간을 사용한 전자시계
2
|
| 7089 | |
| 7086 | |
| 7084 | |
| 7082 | |
| 19677 | |
| 30953 | |
| 7080 | |
| 7077 | |
| 7071 | |
| 7070 | |
| 7066 | |
| 19676 |
JavaScript
구글 웹사이트 번역기를 내 사이트에 달기
|
| 19674 | |
| 27961 | |
| 7063 | |
| 7061 | |
| 19669 | |
| 7060 | |
| 20842 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기