1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Include ()

Discussion in 'PHP' started by TokyoSama, Dec 26, 2011.

  1. #1
    Can someone help me is there any way to used PHP Include () that would work on my php script with an id

    I'm trying to make like this <?php include("myspace.php?id=108001502"); ?> but it giving me error can't open stream is there possible to make it work
     
    TokyoSama, Dec 26, 2011 IP
  2. Rising_Star

    Rising_Star Active Member

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #2
    not possible... one easy thing u can do is..... convert your 'myspace.php' page into a function which is accessible from the page u r calling it.... and then pass the 'id' value to the function
     
    Rising_Star, Dec 26, 2011 IP
  3. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #3
    in addition to what rising_star said, you can also modify the myspace.php to take the parameter id not from get (like $id = $_GET['id']; ) but from the current namespace of your variables (simply do NOT define the parameter $id in your myspace.php) and then define that parameter before your include

    $id = 100000;
    include('myspace.php');
     
    stats, Dec 26, 2011 IP
  4. sharadcool

    sharadcool Greenhorn

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #4
    u can do what stats side you just add
    <?php
    $id=1000;
    include('myspace.php');
    ?>
    and in add $_GET['id'].
     
    sharadcool, Dec 26, 2011 IP
  5. stats

    stats Well-Known Member

    Messages:
    586
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #5
    sharadcool : $_GET is for HTTP GET requests, you can't use it to retrieve a variable from your current namespace ..
     
    stats, Dec 28, 2011 IP
  6. Jaxo

    Jaxo Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #6
    If all the myspace.php page is doing is displaying HTML, you can use file_get_contents()... But I doubt it.

    What you'd need to do is make whatever myspace.php does a function. Then, all you'd need to do is
    include('myspace.php');echo myfunction(108001502);
    PHP:
    .
     
    Jaxo, Dec 31, 2011 IP