Help. read text file with variable names.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madman
Forum Newbie
Posts: 1
Joined: Thu Sep 26, 2002 5:22 am

Help. read text file with variable names.

Post 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.
Craig
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 3:13 pm

Post 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

?>
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

not sure if this is what you are trying to get at, but you could always include the file ....

Code: Select all

include "file.ext";
then the variables should be available to use in your script.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

You have to save it in .php if you have wrote the variables in PHP like

inc.php

Code: Select all

&lt;?php
$VARIABLE1 = "VALUE1";
$VARIABLE2 = "VALUE2";
?&gt;
index.php

Code: Select all

&lt;?php
include("inc.php");

echo $VARIABLE1;
?&gt;
Post Reply