Programming/php2017. 1. 3. 10:25

간단하게 요약(?) 하자면

array에는 되도록이면 'a' 로 해서 확장없이 빠르게 처리하는게 유리할 듯?



echo $data["a"]    이 경우 "a" 안에 치환할게 있는지 검사후 그냥 문자열 "a" 로 인식합니다.

echo $data['a']     이 경우 'a' 는 문자열이므로 바로 $data 에서 index 가 'a' 인 값을 찾을 수 있습니다.

[링크 : http://www.technote.co.kr/php/technote1/board.php?board=study&command=body&no=138]


다음과 같이 더블쿼터의 경우 더블쿼터 안에 있는 문자열에서 변수 등 치환할 값이 있으면 

그를 치환하여 출력한다. 하지만 싱글쿼터의 경우에는 치환할 값을 찾지 않고 그대로 값을 출력한다. 

[링크 : http://luckyyowu.tistory.com/61]


Single quoted

The simplest way to specify a string is to enclose it in single quotes (the character ').

To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash, double it (\\). All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning.

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single]


Double quoted

If the string is enclosed in double-quotes ("), PHP will interpret the following escape sequences for special characters:

As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in \{$var} had not been printed.

The most important feature of double-quoted strings is the fact that variable names will be expanded. See string parsing for details.

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double]


<?php

$juice = "apple";


echo "He drank some $juice juice.".PHP_EOL;

// Invalid. "s" is a valid character for a variable name, but the variable is $juice.

echo "He drank some juice made of $juices.";

// Valid. Explicitly specify the end of the variable name by enclosing it in braces:

echo "He drank some juice made of ${juice}s."

?>


He drank some apple juice.

He drank some juice made of .

He drank some juice made of apples. 

[링크 : http://php.net/manual/en/language.types.string.php]

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.parsing]

'Programming > php' 카테고리의 다른 글

php pack / unpack  (0) 2017.01.04
php foreach / array  (0) 2017.01.03
php class 그리고.. 구조체가 없다?  (0) 2017.01.02
php 변수 스코프  (0) 2017.01.02
php print_r  (0) 2017.01.02
Posted by 구차니