Jump to content

[SOLVED] String object not being treated as a string


semanticdm

Recommended Posts

Hi,

 

I'm working in an environment where I don't have access to SQL, and have had to come up with some interesting methods to try and work around that.

One method I think will work is to use a bunch of flat files, and have a config file to control which files are used.  However, I've run into an issue - when I pull information out of the config file related to filenames of the other files, it doesn't work.

 

The code in question:

$myFile = "./frontpagearticles/testFile.txt";
     $fh = fopen($myFile, 'r');
     $theData = fgets($fh);
     echo file_get_contents( $theData);
     $theData = "./frontpagearticles/" . $theData;
     echo file_get_contents( $theData);
     echo file_get_contents("./frontpagearticles/allstar.txt");

 

testFile.txt is just a simple text file with the names of the files that should be used.

./frontpagearticles/ is the directory that all the articles live in.

If I try

Hard coding in the data

$theData = "./frontpagearticles/allstar.txt"

works.  It's only when I try to pull in the information from the config file that the problem occurs.

 

Any help or ideas of what might be going on would be greatly appreciated.

 

Thanks!

Tom Bowersox

Link to comment
Share on other sites

try using trim(). not sure if this will help but it's worth a shot

 

$myFile = "./frontpagearticles/testFile.txt";

$fh = fopen($myFile, 'r');

$theData = trim(fgets($fh));

echo file_get_contents($theData);

$theData = "./frontpagearticles/" . $theData;

echo file_get_contents($theData);

echo file_get_contents("./frontpagearticles/allstar.txt");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.