What is the best practice for creating SEO-friendly URLs in PHP?

When creating SEO-friendly URLs in PHP, it is important to make them descriptive, relevant to the content, and easy to read for both users and search engines. Avoid using special characters, numbers, or random strings in the URL. Instead, use keywords that accurately describe the page's content. Additionally, consider using dashes to separate words in the URL for better readability and SEO optimization.

// Example of creating an SEO-friendly URL in PHP
$title = "How to Create SEO-Friendly URLs in PHP";
$slug = strtolower(str_replace(' ', '-', $title));

echo $slug; // Output: how-to-create-seo-friendly-urls-in-php