Setting a variable equal to contents of a file

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
richmix
Forum Commoner
Posts: 31
Joined: Fri Dec 22, 2006 5:21 am

Setting a variable equal to contents of a file

Post by richmix »

Hey all, I'm sorry I have to bug you guys with what is probably a very easy-to-answer question, but Google isn't being very friendly with my queries on this one. I just want to know how to set a variable equal to the contents of a particular file, like in the following (non-functional) example:

$var = include('file.php')

I'm trying to create a form mailer that uses templates.

Thanks!
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

file_get_contents()

It's listed in the "filesystem" section of the manual: http://www.php.net/manual/en/ref.filesystem.php

Cheers,
Kieran
richmix
Forum Commoner
Posts: 31
Joined: Fri Dec 22, 2006 5:21 am

Post by richmix »

Yay! Thank you! I looked through that manual, but there are a billion and one entries in it. It's easy to miss what you're looking for.
Post Reply