Web/PHP

PHP 설치 - XAMPP

WakaraNai 2021. 10. 6. 17:39
728x90
반응형

WAMP

Apache + MySQL + PHP 를 Window에서 쓸 수 있도록 만든 프로그램

 

XAMPP

bitnami에서 좀 더 다양한 기능을 제공해주고 있어서 선택

생활코딩에서는 bitnami를 기반으로 설명함

 

설치

https://www.apachefriends.org/index.html

 

XAMPP Installers and Downloads for Apache Friends

What is XAMPP? XAMPP is the most popular PHP development environment XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to us

www.apachefriends.org

 

혹시 몰라서 체크 박스에 있는 것은 다 설치해두었는데, 

생각해보니 그만큼 쓸 것 같지 않았다.

무튼 apache, mysql, mariaDB, php 정도면 충분한 것 같다

 

php 환경설정

C:\xampp\php 경로에서 php.ini 파일을 메모장으로 열기

Ctrl+F로 아래 사진처럼 설정 값 바꿔주기

켜둬야 에러가 떠서 디버깅할 수 있다
cache 저장에 시간 소요하지 말고 결과를 즉시 보려고

 

 

php 실행하기

1. C:\xampp\htdocs 에 test.php 파일 작성하기

2. XAMPP Control Panel에서 Apache 켜기

3. 'localhost/test.php'를 주소칸에 입력

 

+) test.php

결과화면

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
</head>

<body style="width:300px">
  <table border cols=3>
    <?php
      $array = array(
        array('A-101','Downtown',500),
        array('A-102','Perryidge', 400),
        array('A-201', 'Brighton', 900)
      );

      for ( $i=0; $i<3; $i=$i+1)    {
        echo "
            <tr>  <!-- one row-->
              <td>".$array[$i][0]."</td>
              <td>" .$array[$i][1]."</td>
              <td>" .$array[$i][2]."</td>
            </tr>
          ";
      }
    ?>
  </table>
  <center> The <i> account </i> relation</center>

  <form action="BankQuery" method="get">
    Select account or loan and enter number <br>
    <select name = "type">
      <option value = "account" selected> Account </option>
      <option value = "loan"> Loan </option>
    </select>
    <input type="text" size="5" name="number">
    <input type="submit" value="submit">
  </form>
</body>

</html>

 

 

실행 예제 2

경로: C:\xampp\htdocs 

 

sendname.html

<!DOCTYPE html>
<html lang="en">
<head>
  <title> Input Form</title>
</head>

<body>
  <form action="receivename.php" method="post">
    Name <input type="text" name="name"><br>
    <input type="submit" value="send"><br>
  </form>
</body>

</html>

 

 

receivename.php

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
  Hello, 
  <?php
    print($_POST['name']) //super global variable post
  ?> 
</body>
</html>

 

 

 

728x90
반응형

'Web > PHP' 카테고리의 다른 글

[PHP] File Upload  (0) 2021.11.06
SQLite  (0) 2021.10.09
파일 읽고 쓰기 - 간단한 데이터를 다룰 때  (0) 2021.10.09
환경설정 - Apache, PHP  (0) 2021.10.09
PHP + MySQL  (0) 2021.10.09