
<script>
function myfunction1(){
document.getEelmentById(’result’).value = “버튼 1 눌러짐”;
}
function myfunction2(){
document.getEelmentById(’result’).value = “버튼 2 눌러짐”;
}
</script>
<input id = result type=text>
<input type = button value=”버튼1 눌러주세요” onclick=myfunction1()> // 쌍따옴표가 있다면 출력되고 없다면 출력 안됨.
<input type = button value=버튼2 onclick=myfunction2()>
// response, request 사이에 php가 끼여있다라고 생각!
//
여기는 html로 해석됩니다<BR>
<?php
echo “여기는 php의 공간입니다.”; // 출력문
echo “<input type=text>”; // 가능함(html문 첨가)
---
int num = 10; // 아두이노 버전
$num = 10; // php 버전(변수에 $ 기호 붙여야 함)
$num = “10”; // 문자열
// php는 “10” * 10 = 100으로 나옴
---
int num[] = {1,2,3,4}; // c언어의 배열
int num[4];
int num[0] = 1;
int num[1] = 2;
int num[2] = 3;
int num[3] = 4;
$num = {1,2,3,4}; // php의 배열
echo $num[2]; // 3이 출력됨
---
for($i=0;$i<4;$i++){ // php 반복문
echo $num[$i] . “<BR>”;
// 위와 밑은 같은 결과 출력하는 코드
echo $num[$i];
echo “<BR>”;
}
---
$num = [1,2,3,4,5,6];
ehco count($num); // 배열의 갯수를 출력
$cnt = count($num);
?>
localhost = 127.0.0.1 (내 것을 쓰겠다!!)
localhost는 서버의 메인 페이지(index.php)
(IP 주소 = 루트 경로) / (test.php = Request)
404 error : 서버가 찾아보고 유효하지 않을 경우
웹 서버 (정보를 가진 쪽)
웹 클라이언트 (정보를 요구)
1) 클라 → 서버 (접속 시도)
2) 클라 → 서버 (요구 사항 제출)
3) 서버 → 클라 (응답)
4) 연결 해제
url(주소 + 데이터 + 규칙)
php의 단점
⭐ node-red (node.js 블록 코딩)
절대 주소 : IP 주소
ex) 절대 주소
상대 주소 : 웹 페이지 간 옮겨갈 때
ex) 상대 주소
<?php
// name = 지원
if(isset($_GET[’name’])){
echo $_GET[’name’];
echo “<BR>”;
else{
echo “name이 존재하지 않습니다”;
}
if(isset($_GET[’age’])){
echo $_GET[’age’];
echo “<BR>”;
}
else{
echo “age이 존재하지 않습니다”;
}
echo $_GET[’name’];
echo “<BR>”;
echo $_GET[’age’];
echo “<BR>”;
?>
<?php
$data = = ‘<input type=\”text=\”>”; // 쌍따옴표 안에 또 쌍따옴표가 있다면 역 슬래시( \ )를 써야 한다. (나중에 이런 경우 많음)
echo $data;
?>
<table border=1 width = 300>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
<?php
$myarray = [
[’녹칸다1’, ‘21’, ‘남성’, ‘aa1’],
[’녹칸다2’, ‘22’, ‘남성’, ‘aa2’],
[’녹칸다3’, ‘23’, ‘남성’, ‘aa3’],
[’녹칸다4’, ‘24’, ‘남성’, ‘aa4’]
];
for($i=0;$i<count($myarray);$i++){
echo “<tr>”;
for($j=0;$j<4;$j++){
echo “<td>” . $myarray[$i][$j].”</td>”;`
}
echo “</tr>”;
}
</table>
?>