APM(ApachePhpMysql)
-
substrAPM(ApachePhpMysql) 2024. 10. 10. 18:20
$string = "Hello, World!";$result = substr($string, 7, 5); // "World"echo $result; // 출력: World$string = "Hello, World!";$result = substr($string, -6); // "World!"echo $result; // 출력: World!문자열의 일부분 추출substr(string $string, int $start, int $length = null)$string: 추출할 원본 문자열입니다.$start: 추출을 시작할 위치입니다. 문자열의 첫 번째 문자는 0부터 시작합니다. 음수를 지정하면 문자열의 끝에서부터 카운트합니다.$length: 선택적 매개변수로, 추출할 문자열의 길이입니다. 이 매개변수를 지..
-
Json_EncodeAPM(ApachePhpMysql) 2024. 10. 10. 18:20
사용 하는 경우1. Controller에서 JSON으로 응답할 때public function getData() { $data = ['status' => 'success', 'message' => 'Data fetched successfully']; echo json_encode($data);}Controller에서 API 응답이나 AJAX 요청에 대해 JSON 데이터를 직접 반환할 때는 json_encode를 사용.2. View에서 JavaScript로 PHP 데이터를 넘길 때 var calendarData = ;console.log(calendarData);View에서 PHP 배열/객체를 JavaScript에서 사용하기 위해 JSON 형식으로 변환할 때 json_encode를 사용.사용하지 ..
-
foreach문APM(ApachePhpMysql) 2024. 10. 10. 18:20
$calendar = [ 'Spring' => [2024 => ['March', 'April', 'May']], 'Summer' => [2024 => ['June', 'July', 'August']], 'Autumn' => [2024 => ['September', 'October', 'November']], 'Winter' => [2024 => ['December', 'January', 'February']]];foreach ($calendar as $season => $years) { foreach ($years as $year => $months) { foreach ($months as $month) { echo "$season $year: ..
-
die(), exit()APM(ApachePhpMysql) 2024. 9. 20. 18:29
스크립트 실행을 종료합니다.종료 함수와 객체 소멸자는 exit가 호출 되더라도 항상 실행됩니다. die(), exit() 동일하게 사용한다 예) ajax통신 중 header가 딸려올때 호출해서 사용한다. die 이전에 코드가 실행되고 die이후에 코딩은 중단된다 CI에서 사용되는 정석적인 return방법 ↓ ↓ ↓ ↓ ↓ ↓ return $this->output->set_content_type('application/json')->set_output(json_encode()); Content-Type을 application/json으로 설정하여 JSON 형식의 데이터를 응답으로 보냅니다.json_encode()를 사용해 배열이나 객체 데이터를 JSON 문자열로 변환하여 응답 본문으로 설정합니다.클라이언트..
-
SSL 인증서APM(ApachePhpMysql) 2024. 9. 9. 18:35
1. Window Powershell 관리자 권환으로 실행2. Get-ExecutionPolicy 입력Restricted가 아닐 경우 Set-ExecutionPolicy AllSigned 실행 후 Y 입력3. Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))입력4. choco 입력..