JavaScript와 PHP의 변수 선언 방법은 다르다.


JavaScript 변수 선언은 그냥 선언하면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>생활코딩</title>
  </head>
  <body>
    <h1>JavaScript</h1>
    <script>
      name = "hey java script";
      document.write(name+" Hello~");
    </script>
  </body>
</html>
cs

PHP 변수 선언은  앞에 $기호를 추가하면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>생활코딩</title>
  </head>
  <body>
    <h1>PHP</h1>
    <?php
    $name = "hey php";
    echo $name." Hello~";
    ?>
  </body>
</html>
cs


+ Recent posts