Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy How to print upper folder PHP

    Hello can anyone tell me how to print upper folder in PHP from the file which is located in sub folder..

    eg: public_html / mysite / music / new / index.php

    PHP Code:
    $home =  'http://mysite.com/';
    $current_folder basename(dirname(__FILE__));
    echo 
    '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'
    In this code I can link to currennt folder 'new' but how do I link 'music' folder in this script..

    Pls Help... Tnx n advance
    Last edited by coolabhi; 03-01-2009 at 03:46 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Like
    PHP Code:
    echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'
    since the php variable won't get parsed, when used inside single quotes.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Like
    PHP Code:
    echo '<a href="'.$home.'">Home</a> / <a href="'.$home.$current_folder.'">'.$current_folder.'</a><br/>'
    since the php variable won't get parsed, when used inside single quotes.
    Aww thanks corrected.. can any1 help me out.......

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    $path="public_html/mysite/music/new/index.php";
    $dirs=explode('/',$path);
    #print_r($dirs);
    echo $parent=$dirs[count($dirs)-3]; 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •