W3docs

Proper URL forming with a query string and an anchor hashtag

To form a proper URL with a query string and an anchor hashtag in PHP, you can use the http_build_query() function to create the query string and concatenate it to the base URL using the ?

To form a proper URL with a query string and an anchor hashtag in PHP, you can use the http_build_query() function to create the query string and concatenate it to the base URL using the ? symbol, followed by the anchor hashtag using the # symbol.

Example:

Example of forming a proper URL with a query string and an anchor hashtag in PHP with http_build_query() function

php— editable, runs on the server

This will create a URL like http://www.example.com?param1=value1&param2=value2#section1.