Results 1 to 3 of 3

Thread: get data from external site & translate variables

  1. #1
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default get data from external site & translate variables

    Does anyone know of a way to have two files, one that says something like:

    file.php
    PHP Code:
    <?php
    $varofpie 
    'i like $type $pie.';
    ?>
    then another file that says

    PHP Code:
    <?php
    $type 
    ";apple";
    $pie "pie";
    require(
    "file.php");
    echo 
    $varofpie;
    ?>
    Is there a way to make it so that I can get something from an other file but it still translates variables?

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by motormichael12 View Post
    file.php
    PHP Code:
    <?php
    $varofpie 
    'i like $type $pie.';
    ?>
    then another file that says

    PHP Code:
    <?php
    $type 
    ";apple";
    $pie "pie";
    require(
    "file.php");
    echo 
    $varofpie;
    ?>
    Is there a way to make it so that I can get something from an other file but it still translates variables?
    What you've posted would've worked if only you'd used the opposite form of quotation mark in each case.

    Variables are not expanded in string literals that use single quotes, and only two escape sequences (\\ and \') are replaced. Use double quotes where expansion is necessary - I'd use single quotes everywhere else.

    Mike

  3. #3
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    Code:
    <?php
    $varofpie = "i like $type $pie.";
    ?>
    and
    Code:
    <?php
    $type = 'apple';
    $pie = 'pie';
    require("file.php");
    echo $varofpie;
    ?>
    worked...


    Thanks very much, I have been trying to do that for a while.

Bookmarks

Posting Permissions

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