Reply to Re: recognize url where file is

Your name:

Reply:


Posted by C. on 10/05/07 14:49

On 1 Oct, 15:03, ne...@no-log.org (denisb) wrote:
> artev <mailnotspa...@notspamm.nn> wrote:
> > If I am inhttp://localhost/A/test.php
> > I want in php a code (or function) that print:
> >http://localhost/A/
> > is there a function that to do all?
>
> have a look at <http://fr2.php.net/manual/en/function.parse-url.php>
> (comment by kjensen_at_nospam_dot_iaff106_dot_com at bottom of the page)
>
> <?php
>
> function ParseURLplus($url) {
> $URLpcs = (parse_url($url));
> $PathPcs = explode("/", $URLpcs['path']);
> $URLpcs['file'] = end($PathPcs);
> unset($PathPcs[key($PathPcs)]);
> $URLpcs['dir'] = implode("/", $PathPcs);
> return ($URLpcs);
>
> }
>
> $url1 = 'http://www.example.com/path/dir/file.php?arg=val#anchor';
> $URL1pcs = ParseURLplus($url1);
> print_r($URL1pcs);
>
> /*
> Array(
> [scheme] => http
> [host] =>www.example.com
> [path] => /path/dir/file.php
> [query] => arg=val
> [fragment] => anchor
> [file] => file.php
> [dir] => /path/dir
> )
> */
>
> $url2 = 'https://name:p...@www.example.com/dir/file.php?arg=val#anchor';
> $URL2pcs = ParseURLplus($url2);
> print_r($URL2pcs);
>
> /*
> Array(
> [scheme] => https
> [host] =>www.example.com
> [user] => name
> [pass] => pass
> [path] => /dir/file.php
> [query] => arg=val
> [fragment] => anchor
> [file] => file.php
> [dir] => /dir
> )
> */
>
> ?>
>
> HTH
> --
> @@@@@
> E -00 comme on est very beaux dis !
> ' `) /
> |\_ =="

or dirname(realpath($url))

C.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация