PHP includes fuction troubleshooting

Discussion in 'PHP' started by unl0ad, Apr 6, 2007.

  1. #1
    Ok im trying to include an html file inside some php quotes... heres what i got so far that does not work, i really cannot find the problem. Inside the 1001 files is plain HTML.



    $bannersee = "<center>
    
    
    
      <a href='http://www.x.net/' target='blank'><img src='http://www.x.com/images/x.jpg' alt=X' border='0' /></a><br>
    
    <br>".include( "/home/httpd/vhosts/x.com/httpdocs/hardlinks/data/output/1001" )."";
    
    
    
    echo "</center>";
    
    dcb("Friends", 3, $bannersee);
    PHP:

     
    unl0ad, Apr 6, 2007 IP
  2. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #2

    The php part should be like this:


    $bannersee = "<center>
    <a href=\"http://www.x.net/\" target=\"blank\">
    <img src=\"http://www.x.com/images/x.jpg\" alt=\"X\" border=\"0\" /></a><br>

    <br><br>".
    include( "/home/httpd/vhosts/x.com/httpdocs/hardlinks/data/output/1001" );
    echo "</center>";
    dcb("Friends", 3, $bannersee);

    Or, u can try this:

    $bannersee = "<center><a href=http://www.x.net/ target=blank>
    <img src=http://www.x.com/images/x.jpg alt=X border=0 /></a><br>

    <br><br>".
    include( "/home/httpd/vhosts/x.com/httpdocs/hardlinks/data/output/1001" );
    echo "</center>";
    dcb("Friends", 3, $bannersee);
     
    srobona, Apr 6, 2007 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't even think that would work as include doesn't return strings, it processes files and would output the HTML straight away that is included.

    There's nothing wrong with the use of quotes that I can see. Essentially the problem is that include doesn't work how you seem to think it works.

    If you want get the contents of a file into a variable, instead of using the include to append the content to a string, use the file_get_contents() function to read the HTML (content) from the file into a variable and then append that new variable in place of the include.
     
    TwistMyArm, Apr 6, 2007 IP
  4. unl0ad

    unl0ad Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    nice work twist, fixed it :)
     
    unl0ad, Apr 6, 2007 IP