Diving into PHP: Day 12
We’ll take a short break from working with MySQL in order to analyze how to work with the file system. Today, you’ll learn how to use the “file” function, as well as “fopen”, “fgets”, and “fputs”.
Day 12: Files
Be sure to click on the “Full Screen Toggle”.
- Subscribe to the Theme Forest RSS Feed.



















Woo… first comment. Jeff you’re awesome!
and another wonderful tut , thanks Jeff
Good Stuff
Nice to see you using e-text editor

Did you like it?
Take a look at the php and html bundles for the next time… they will save you more time
For example, if you wanna write a parragraph, ul, li, and so just ALT+< or if you wanna make a foreach jusft foreach+tab.
Really great tut as ever
Nice tutorial! I have to admit I prefer the PHP and MYSQL tutorials, but these are extremely useful for me. I did a simple file upload thing for my website, that didnt work out half as well sa this lol.
I’m learning PHP… Oh yeah!!!!!!
Thanks Jeff, you’re awesome!
Damm you Jeffrey, where were you when I was learning this stuff?
You make it so easy.
btw: this is great mind refresher.
Great tut as always! Maybe in the next tut you could explain when .txt files are better to use than a database when storing information?
Thanks!!!
@ Meshach – read your comment right after I posted, for a momment I got big headed and thought you were talking to me lol.
To Jeff Way – how do you even find the time do all this stuff!!!!:?
Jeff,
we all cannot appreciate you enough for this great work. Like i always end my comments, God bless you man. Hey as part of the more advanced php tuts that you will be doing is LDAP going to feature? using LDAP for single login to applications would be awesome.
Thanks, guys. I’m glad to hear it’s helping. This stuff is hard! Videos help.
Excellent tutorial as always.
One criticism I have though is that it’s quite annoying that you change text editors so often. It really harms the consistency and continuity of the series.
Dan
Thanks Jeff, I’ve been enjoying your tutorials for months and haven’t thanked you yet.
Are you planning on covering uploading things like audio files or video?
Thanks again
Scott
@Dan – I disagree. I think it allows the newer users to take a look at many different editors….to make up their own mind.
Wow. tnx!
I’ve been following this series from the begining and i appreciate editor changes ! I agree with you, it’s nice to open our work space to different tools and i’ve discovered many, since i’ve been watching.
Thank’s a lot Jeffrey.
A french fan !
Ned
@Jeffry Way – You have caused me to buy a new editor today, but I LOVE IT! Been looking for something like this for awhile now. Had to ditch my Pro for various reasons, and could never find anything equivalent to TextMate (in terms of look, feel, etc.)
Danke!
awesome! waiting for 13
Thank’s a lot Jeffrey.
@Matt – Enjoy it! Check out the bundles and “Control Alt P”.
excellent Job.
Ehi! Thanks for this but where are the others lessons? I’ve found only from here to lesson number 10!
Please let me know
Sorry I’ve seen the links to the others videos right now!
Thanks a lot
Hey all, I have a quick question:
Jeff talks about storing only “smaller files” into the memory, when using fopen. I was wondering if anyone knew how big a file can be before one MUST separate the file, line-by-line. I’m developing a CSS formatting and optimizing WordPress plugin, and want to know the limitations.
Should I be worried about files <100kb in size?
Thanks, in advance.
@Jeffrey:
Thanks so much for these screen casts!
What is the file is very large and contains only one line?
Hey! Awesome tutorial. Could anyone tell me what the editor is that is shown in the video?
Thanks!
Hey Jeff…I’ve followed along your screencast for the past week, daily…literally. I feel like I owe you a debt but I’ve tried and tried to subscribe to this RSS feed and cant figure it out for the hell of it. I dont have any of those readers im registered with and don’t really understand the concept of WHAT it is? It doesnt have just a place to put your email so its obviously not a mailing list. You probably dont have to answer this personally theres over 6000+ users and SOMEBODY HELP ME OUT PLEASE! I’m not computer illiterate so you can be brief! Thanks!
Jeff quick question…in the 1st example why did we use $fp = file(file.txt); and not $fp = file_get_contents(file.txt)….?
I would love if you could do a tutorial that go thru the basics of handling xml files.
Keep up the good work, I love these tutorials
/Nick
it’s gonna amazing and helpfull ,even if i haven’t seen it yet ,but i assume that because i know you are a skilled guy Jeffery.
i read an article on nettuts about the oop ,but still can’t figure out what’s this ,is it something hard to understand ?
or because as a beginner its normal to see it like that???
Jeffery! I am really looking forward to see what comes next. Could you show us how to create a user registration?
Thank you so much for taking the time to go over this stuff with us.
I ordered your recommendation, PHP Solutions.
Regards,
Paul
Thanks Jeff! I cant wait for day 13.
I have been reading 3 different PHP books and this makes learning
it more efficient than all of them.
Thanks again,
Paul
I’m a seriouse beginner and im having trouble echoing out the file into my browser in index3.php
Any Help?
Well done Jeff, great site, great tuts.
@jeffrey way. Does this only work in .txt files?
@Jeffrey
Thank you so much!
I needed this for a project and it cleared up this ‘fopen’ topic so well for me.
Also about the text editors, I like that you use different types of software, it’s good to see so many different approaches to writing php!
Keep it up
Are there not going to be any more of these?
@Jason
He has made more, he’s gone up to 16: http://blog.themeforest.net/tutorials/diving-into-php-day-16/