Page 1 of 1

Set a variable to the contents of a file.

Posted: Sat Nov 26, 2005 3:08 pm
by Majoraslayer
How might I set a variable to the contents of a text file? I learned the following doesn't work, though by looking at it I'm sure you'll figure out what I was wanting:

$content_index = include('html/index.html');

Posted: Sat Nov 26, 2005 3:10 pm
by shiznatix

Code: Select all

$contents = file_get_contents("somefile.txt");

Posted: Sat Nov 26, 2005 3:24 pm
by Majoraslayer
...I love you :o

Posted: Sat Nov 26, 2005 3:58 pm
by foobar
Hey Majorslayer, you might want to check out the PHP Manual. No joke! It's one of the best php resources out there. I use it _all_ the time. It'll give you good answers faster than you think. :wink:

Posted: Mon Nov 28, 2005 1:08 am
by Majoraslayer
Yep, fish through 3 million commands when I could just as easily ask some experienced people. I see the logic :wink:

Posted: Mon Nov 28, 2005 6:51 am
by Roja
Majoraslayer wrote:Yep, fish through 3 million commands when I could just as easily ask some experienced people. I see the logic :wink:
In case its not clear, let me explain it.

First, you don't have to fish through it. The search on php.net's manual is top-notch, even better (because it is so focused) than google in many cases.

Second, the only reason the experienced people *can* answer questions is because users take the time to try to fix the problem, look for answers online, and only when they get truly stumped ask questions. We'd literally never have time if we tried to replace the manual or google.

Not trying to be short or rude, but trust me, you won't get answers for long if you won't take those simple first steps.

Posted: Tue Nov 29, 2005 9:00 am
by Majoraslayer
Roja wrote:
Majoraslayer wrote:Yep, fish through 3 million commands when I could just as easily ask some experienced people. I see the logic :wink:
In case its not clear, let me explain it.

First, you don't have to fish through it. The search on php.net's manual is top-notch, even better (because it is so focused) than google in many cases.

Second, the only reason the experienced people *can* answer questions is because users take the time to try to fix the problem, look for answers online, and only when they get truly stumped ask questions. We'd literally never have time if we tried to replace the manual or google.

Not trying to be short or rude, but trust me, you won't get answers for long if you won't take those simple first steps.
Sorry, didn't mean to offend :oops:

I was just kidding, and I forgot the manual was online >_<.