
arg_separator.output 설정을 변경하여 '?'로 설정할 수 있습니다.
이때, URL에서 '&'를 '?'로 대체하려면, PHP의 built-in 함수인 http_build_query()를 사용하여 URL 인코딩을 변경할 수 있습니다.
예를 들어, 다음과 같이 사용할 수 있습니다.
#hostingforum.kr
php
$url = 'http://example.com/index.php?name=John&age=30';
$params = array('name' => 'John', 'age' => 30);
$query = http_build_query($params, '', '?');
$newUrl = str_replace('&', '?', $url) . $query;
print($newUrl); // http://example.com/index.php?name=John?age=30
또는, PHP 7.4 이상부터는 http_build_query() 함수의 세 번째 인자로 '?'를 지정하여 '?'로 인코딩할 수 있습니다.
#hostingforum.kr
php
$url = 'http://example.com/index.php?name=John&age=30';
$params = array('name' => 'John', 'age' => 30);
$query = http_build_query($params, '', '?');
$newUrl = $url . $query;
print($newUrl); // http://example.com/index.php?name=John?age=30
이러한 방법으로 URL에서 '&'를 '?'로 대체할 수 있습니다.
2025-03-17 03:46