Jump to content

Archived

This topic is now archived and is closed to further replies.

smartguyin

Can we use the part from url and set it as variable

Recommended Posts

I want to use the part from url like http://www.domain.com/product.php

Soo 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....

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[code]<?php

$filename = substr(basename($_SERVER['PHP_SELF']),0,-4);

?>[/code]

Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.