<?
$br = "<br>";
?>
<html>
<head><title>환경변수</title></head>
<body>
<?
if($your_name && $your_phone){
echo "{$your_name}님의 전화번호는 {$your_phone}입니다";
}
?>
<!--
<form name = form action = "ex.php" method=post>
post: 보내는 방식.보안에 좋음, get:보안에 않좋음.
-->
<!-- <form name = form action = "<?=$_SERVER[PHP_SELF]?>" method=post> -->
<form name = form method=post action = "ex2.html">
<font face=굴림 size=2>
이름 : <input type = "text" name = "your_name"> <br>
전화 : <input type = "text" name = "your_phone"> <br>
<input type="submit" value="send">
</font>
</form>
</body>
</html>
환경변수
PHP_SELF : 현 파일이름.
DOCUMENT_ROOT: 현파일의 절대경로
REMOTE_ADDR : 사용자의 IP주소
환경변수 사용시 $_SERVER 로 감싼다.
$_SERVER[REMOTE_ADDR]
2012년 8월 19일 일요일
php test
<?
$br = "<br>";
?>
<?
$file = "fopen_test.txt";
if(file_exists($file)==false){
echo "file not found:".$file;
return;
}
$fp = fopen($file,r);
if(!$fp){
echo "failed to open";
} else {
$contents = fread($fp,filesize($file));
echo $contents;
}
fclose($fp);
echo $br;
echo "read ok";
$fp = fopen($file,a);
if(!$fp){
echo "failed to open";
}else {
$str = "append string ok추가";
fwrite($fp,$str.$br);
fclose($fp);
}
echo $br."ok! insert";
?>
$br = "<br>";
?>
<?
$file = "fopen_test.txt";
if(file_exists($file)==false){
echo "file not found:".$file;
return;
}
$fp = fopen($file,r);
if(!$fp){
echo "failed to open";
} else {
$contents = fread($fp,filesize($file));
echo $contents;
}
fclose($fp);
echo $br;
echo "read ok";
$fp = fopen($file,a);
if(!$fp){
echo "failed to open";
}else {
$str = "append string ok추가";
fwrite($fp,$str.$br);
fclose($fp);
}
echo $br."ok! insert";
?>
피드 구독하기:
덧글 (Atom)