smartguyin Posted September 9, 2006 Share Posted September 9, 2006 I want to use the part from url like http://www.domain.com/product.phpSoo i want to set the variable to catch only "product" and leaving the other content in the url...Soo in this example i have to exclude 22 character ( http://www.domain.com/ ) from start and 4 characters ( .php ) from End.I know this is possible have any one tried this one.... If yes please let me know..... waiting for your replies.... Link to comment https://forums.phpfreaks.com/topic/20214-can-we-use-the-part-from-url-and-set-it-as-variable/ Share on other sites More sharing options...
Pezzoni Posted September 9, 2006 Share Posted September 9, 2006 Would it not be simpler to just set a variable for each page? So for example, at the top of index.php, you have a line saying:[code]$page = 'index';[/code]And at the top of product .php, you have a line that says:[code]$page = 'product';[/code]You could do it in the way you are suggesting, but it would be needlessly complex. Link to comment https://forums.phpfreaks.com/topic/20214-can-we-use-the-part-from-url-and-set-it-as-variable/#findComment-88918 Share on other sites More sharing options...
smartguyin Posted September 9, 2006 Author Share Posted September 9, 2006 no coz the website is already with many pages and its difficult to set var.. to every page.Soo i am trying to do this. Actually i want that variable to echo in my title tag and some parts of the body soo i want to try it out this one. have u ever tried it please give me ints and i'll foloow up. Link to comment https://forums.phpfreaks.com/topic/20214-can-we-use-the-part-from-url-and-set-it-as-variable/#findComment-88920 Share on other sites More sharing options...
Orio Posted September 9, 2006 Share Posted September 9, 2006 [code]<?php$filename = substr(basename($_SERVER['PHP_SELF']),0,-4);?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/20214-can-we-use-the-part-from-url-and-set-it-as-variable/#findComment-88926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.