1. 스트링(String)

<php
$hello = "hello world";
$hello2 = 'hello world';
echo $hello;

싱글 쿼트, 더블 쿼트 모두 스트링 타입입니다.

2. 인티저(Integer)
음수와 0, 양수입니다.(-2,147,483,648~2,147,483,647)

$number = "12";
echo (int)$number;

(int)를 추가하면 int형으로 캐스팅 됩니다.(형변환)

3.플로트(Float)

$float = 11.2;

4. 불리언(Boolean)

$check = true;
$check = false;

5. 배열(Array)

$arrays = array();

6. 객체(Object)

$color = new color("black", "white");

7. NULL

$is_null = null;

자바스크립트에서는 연관 배열이 없기 때문에 배열은 index와 index의 값을 가질수 있습니다.

var shopping = ["bread", "milk", "cheese", "hummus", "noodles"];
console.log(shopping);

연관 배열 처럼 할려면 javaScript에서는 Object를 사용해야 합니다.


아래는 PHP 배열 입니다.

$association = array("val" => 1, "txt" => "연관배열");
$association = array(
	array("val" => 1, "txt" => "연관1"),
	array("val" => 2, "txt" => "연관2"),
);

 

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

문자 변환, 변경, 치환  (0) 2023.10.22
PHP의 데이터 타입(data type)  (0) 2023.10.20
글자 길이가 길 때 글자 줄이는 방법(...)  (0) 2023.10.18
filter_var 숫자(int) 체크  (0) 2023.10.16
특정 날짜의 요일 구하기  (0) 2023.10.07

+ Recent posts