Page 1 of 1
Help. read text file with variable names.
Posted: Thu Sep 26, 2002 5:22 am
by madman
Hello.
I have a txt file with some variable names in it. Is
there any way to take the value of the variable
through php.
Thank you.
Posted: Thu Sep 26, 2002 7:29 am
by Craig
if it's just a normal text file then anyone would be able to view it through there browser and it wouldn't pass the variables I don't think.
You need to enclose the variables within
<?php
tags at the top and bottom of the file
?>
Posted: Thu Sep 26, 2002 7:33 am
by Wayne
not sure if this is what you are trying to get at, but you could always include the file ....
then the variables should be available to use in your script.
Posted: Thu Sep 26, 2002 7:46 am
by volka
but still the 'code'-block has to be marked with <?php ... ?>
otherwise the content of the file will be written to browser as it would be if you had text outside a php-block in your main-script
Posted: Thu Sep 26, 2002 4:37 pm
by Takuma
You have to save it in .php if you have wrote the variables in PHP like
inc.php
Code: Select all
<?php
$VARIABLE1 = "VALUE1";
$VARIABLE2 = "VALUE2";
?>
index.php
Code: Select all
<?php
include("inc.php");
echo $VARIABLE1;
?>