What are the best practices for creating user-friendly URLs in PHP?

When creating user-friendly URLs in PHP, it is important to keep them simple, descriptive, and easy to read. Avoid using special characters, symbols, or numbers that may confuse users. Instead, use meaningful words that accurately describe the content of the page.

// Example of creating a user-friendly URL in PHP
$title = "This is a sample page title";
$url = strtolower(str_replace(' ', '-', $title));
echo $url; // Output: this-is-a-sample-page-title