Help with my $variable !

Discussion in 'PHP' started by Dollar, Dec 15, 2007.

  1. #1
    I have php file that calls $url from the config.php file threw include.

    I set the variable to
    config
    $url  = 'http://www.mysite.com/';
    PHP:

    Now on the the other php file I have a line like this

    <a href=\"$url/images/1/\">Page 1</a>

    So this would parse it and insert that variable that in there making it
    <a href="http://www.mysite.com//images/1/>page 1</a>
    The only problem is it puts a double // after the domain. like mysite.com//images/1
    So If Remove the / and put a space then the url is broken. If I put the $url right up "images" then obviously the Variable won't work.. What should I put after $url in the that line??
     
    Dollar, Dec 15, 2007 IP
  2. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Make it this

    
    $url  = 'http://www.mysite.com';
    
    PHP:

    Or if you do not want to change the url variable you could do something like this:

    
    <a href=\"".$url."images/1/\">Page 1</a>
    
    PHP:
    There is also a way to do it with {$url} but I cannot remember if it's single quotes that works or double. I don't mix html and PHP often so can't remember that one off the top of my head.
     
    InFloW, Dec 15, 2007 IP
    Dollar likes this.
  3. Dollar

    Dollar Active Member

    Messages:
    2,598
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Thanks the ".$url." works , Actually I did think of removing the / of the Variable in the config but then I would have to go back and edit a bunch of other files.
     
    Dollar, Dec 15, 2007 IP