Log in

View Full Version : get data from external site & translate variables



motormichael12
12-24-2006, 07:35 PM
Does anyone know of a way to have two files, one that says something like:

file.php

<?php
$varofpie = 'i like $type $pie.';
?>

then another file that says



<?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?

mwinter
12-24-2006, 09:20 PM
file.php


<?php
$varofpie = 'i like $type $pie.';
?>


then another file that says



<?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

motormichael12
12-24-2006, 09:31 PM
<?php
$varofpie = "i like $type $pie.";
?>

and

<?php
$type = 'apple';
$pie = 'pie';
require("file.php");
echo $varofpie;
?>

worked...


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