I have a domain name say for example : www.example.com I would like to get a dynamic data using PHP that is after this domain name. Example : www.example.com/samsung
This will give you last part of url
$url = $_SERVER['PHP_SELF'];
$url_array = explode('/',$url);
$result = end($url_array);
$Cleaned_url = str_replace("?", "", $result);
echo $Cleaned_url;
UPDATE : Creating Seo url :
.htaccess
File
RewriteRule ^([a-zA-Z0-9_-]+)$ your_page.php?p=$1 [L,NC]
In php file when linking to url.
I save urls in database in news_url column
" title="">post title
This setup will give you www.example.com/samsung
and solve your 404 notfound problem with right setup.
Attetion : Creating seo urls with htaccess requires knowledge just copy paste wont work.
you can search on google : for how to create seo url with htaccess
This examples are working 100%.