
strtoupper 함수를 사용하여 "hello world" 문자열을 모두 대문자로 변환하는 방법은 다음과 같습니다.
1. strtoupper 함수를 사용하여 문자열을 대문자로 변환하는 예제는 다음과 같습니다.
#hostingforum.kr
php
$string = "hello world";
$upperCaseString = strtoupper($string);
echo $upperCaseString; // 출력: HELLO WORLD
strtoupper 함수는 문자열 내의 특정 문자만 대문자로 변환하는 기능을 가지고 있지 않습니다. 대신, 이 함수는 문자열 내의 모든 문자를 대문자로 변환합니다.
만약 특정 문자만 대문자로 변환하고 싶다면, str_replace 함수를 사용하는 방법이 있습니다.
#hostingforum.kr
php
$string = "hello world";
$upperCaseString = str_replace("hello", strtoupper("hello"), $string);
echo $upperCaseString; // 출력: HELLO world
이 예제에서 "hello" 문자열만 대문자로 변환합니다.
2025-05-19 00:27