웹페이지 만들기
# 돔(저번주/ 숙제) stringnum display 등등 date는 제외
3. PHP 파일 읽고 쓰기
3개의 문제가 출제된다.
듀얼모니터 사용가능 쉐어링만 안하면 ㅇㅋ
이지하고 가볍고 다양한 플랫폼과 호환성을 지원하기 때문이다.
php external
echo "hello"; : hello를 화면에 출력
echo등 EcHo등 가능하다.$var로 변수를 선언한다. ex. $color = "red"2-1. (출력문 등에서)변수의 연결은 +가 아닌 .으로 진행한다.echo "I love $txt!";같이 처리도 가능하다.#,/, /**/ 으로 처리가 가능하다. Loosely Typed Languague
데이터 타입을 그때 결정
7에서는 추가되엇다느데 나중에.
local, global, static
! global scope는 다른 언어들과는 다르게, 로컬 변수에 접근하는 것이 불가능하다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_var_global
그렇다고 접근을 못하는 거냐, 하면은 그건 또 아니다.
함수 내에 global GLOBALS['x']로 작성해도 된다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_var_globals


로컬변수는 동일하다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_var_local
static은 한 번 선언이 된 후가 초기화가 안되고 그대로 유지해나가는 변수이다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_var_static

이렇게 하면 0 0 0이 아니라 0 1 2가 출력된다.
echo : 리턴값 x, 처리가 살짝 빠른다.
print : 리터값 o, arg를 받는다.

html 태그를 생성하면서 반환이 가능하다.
String, integer, float, boolean, array
디버겅 var_dump(); ->어떤 값을 가지고 있는지 확인할 수 있다.
https://www.w3schools.com/php/func_var_var_dump.asp
+) 배열 선언은 ('ㅁ','ㄴ','ㅇ','ㄹ')식으로 진행된다.

객체도 지원한다.
__construct(){}
php 리솟 strlen : 글자수 확인str_word_count() - 단어의 수strpos(string, target_word) : 글자를 찾아서 인덱스를 리턴 https://www.w3schools.com/php/phptryit.asp?filename=tryphp_string_posstr_replace(orginal, changeYouWant , targetString) : strrev() : reverseOrder
is_int(): int변수인지 확인. float도 동일
is_infinite() : 값이 넘쳤나
is_nan():
is_numeric() : string여도 숫자만으로 이루어져 있느면 true 출력
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_numbers_numeric
그외 수학 함수들...
(int)$x 같이 타입 캐스팅을 해주면 된다.
상수는 $로 선언하지 않고 대문자로 쓴다.
define(name(변수 이름), value(변수 값), case_insensitive(대소문자 구별))로 정의가 가능하다. https://www.w3schools.com/php/phptryit.asp?filename=tryphp_constant1
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_constant2
배열 타입도 상수로 정의 가능하다.
상수의 정의는 완전한 글로벌 변수이다.
===, !===은 자바 스크립트와 동일하다.
<=>을 사용하여 -1,0,1을 리턴하는 compareTo를 만들 수 있다.

배열의 더하기도 가능하다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_oper_arr_union
:? 삼항연산자
?? : null나오다가 정상 잡 나오면 리턴 https://www.w3schools.com/php/phptryit.asp?filename=tryphp_oper_null_coalescing
foreach : 
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_oper_null_coalescing
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_loop_foreach2

앞엣 말했듯 함수 이름에는 대소문자를 구별하지 않는다.
원래는 타입을 안써도 됐지만, php7부터는 타입을 선언해주는 것도 가능해졌다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_non-strict
그래도 loose하게 타입 선언이 되는데(달라도 일단은 ㄱㄱ)
declare(strict_types = 1);을 상단에 사용하면은 다른 언어처럼 엄격한 캐스팅이 된다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_return_strict
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_return_strict2

함수에도 파이썬처럼 :을 사용하여 타입 선언이 가능하다.
기본 arg 선언이 가능 : 
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_function4
참조도 가능하다. (&)
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_pass_ref

인덱스 0,1,2 다른언어랑 동일하다. 당연히 접근도 다른 언어랑 동일하게 가능하다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_num
크기를 구하는 함수로는 count와 sizeof가 있다.
$cars = array("Volvo", "BMW", "Toyota");
echo count($cars) . '<br>';
echo sizeof($cars);
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_length
딕셔너리 구조라 생각하면 편하다. 다만 "key" => "value"형식으로 작성한다.

사진을 보듯이 foreach문으로 접근이 가능하다.
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_assoc_loop
array()안에 array()가 있다.
초기화만 array()로 하는거 주의하면 될 듯 하다.

https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_multi
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_multi2
sort ( ) - sort arrays in ascending order
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_sort_alpha
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_sort_num
rsort ( ) – sort arrays in descending order
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_rsort_alpha
asort( ) – value값 정렬 arsort()도 있음 https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_asort
ksort( ) – key값 정렬 https://www.w3schools.com/php/phptryit.asp?filename=tryphp_array_ksort
어떤 범위에서도 접근이 가능하다. 파일을 넘어서도 접근이 가능하다.
$GLOBALS, $_SERVER, $_REQUEST, $_POST, $_GET, $_FILES, $_ENV, $_COOKIE, $_SESSION
예시) 위에 적어놨던 글로벌 선언 중 하나

$_SEVER[]

php path 정보 : 자주 씀.
https://tryphp.w3schools.com/showphp.php?filename=demo_global_server


https://tryphp.w3schools.com/showphp.php?filename=demo_global_post
5. $_GET[] : get만
https://tryphp.w3schools.com/showphp.php?filename=demo_global_get


php에서 뭘 찾을 때 사용한다.
Syntax
/ : the delimiter
w3schools : the pattern that is being searched for
i : a modifier that makes the search case-insensitive.
만족하는 패턴 찾기 -> preg_match() https://www.w3schools.com/php/phptryit.asp?filename=tryphp_regex_match
만족하는 여러 패턴 찾기 -> preg_match_all() https://www.w3schools.com/php/phptryit.asp?filename=tryphp_regex_match_all
값 변환 https://www.w3schools.com/php/phptryit.asp?filename=tryphp_regex_replace
patterns wannachange targetstring
반복 - 그룹핑
https://www.w3schools.com/php/phptryit.asp?filename=tryphp_regex_grouping
ba다음 na가 두번 나오는 / 대소문자 구병 x