Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
PHP module H109
Input / Output
Exercises, examples and other material relating to training module H109. This topic is presented on public courses Learning to program in PHP, PHP Programming, PHP Programming, Learning to program in PHP

Between accesses to your web pages, data will be stored in data files or in SQL databases. There will also be many applications where initial data is provided in files, or web applications are used to add content to files or make amendments.

Articles and tips on this subjectupdated
4483Moving from mysql to mysqli - simple worked example
We have a big codebase of PHP code that uses MySQL databases, much of it written using mysql_ functions which were not object orineted in nature, and have been paralleled by the more recent mysqli_ functions and methods for quite some time now. The older mysql library is now deprecated, with warnings ...
3424Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP
If you divide £10,000 between 17 lucky children, each gets £588.23 ... but if you divide the number 10,000 by the number 17, you get 588.235294117647. How do you format the data to the appropriate number of decimal places? In Ruby, you can use the % operator on a string - which is an alias ...
3159Returning multiple values from a function call in various languages - a comparison
I've always thought it a bit odd that you call a function with any number of parameters, and yet it returns a single value; in Java, C or C++ you declare a return type (void if there is not to be anything returned) and you are then constrained by that specification. There are, of course, other ways ...
3029PHP data sources - other web servers, large data flows, and the client (browser)
As always, I've written a sprinkling of new demonstrations amongst some well-trodden example during the PHP course I'm presenting this week: There's a really short example of how you can call up another server from your own server - [here]. So much more can be made of the web by presenting and combining ...
2964An introduction to file handling in programs - buffering, standard in and out, and file handles
Stdout and Stderr Programmers typically don't write code to output to the screen / current window, as to to so would be to provide an inflexible system - instead, they output to what's known as "standard out", also known as stdout. Usually stdout defaults to the screen / current window so there's no ...
1780Server overloading - turns out to be feof in PHP
From the manual page on feof: Warning - If passed file pointer is not valid you may get an infinite loop, because EOF fails to return TRUE. From a script on our server: while (1) {   $nlines ++;   $line = fgets($fh,1024);   if (feof($fh)) break; OOps! ... the file that's ...
1442Reading a file multiple times - file pointers
When you open a file for read, you create a "file pointer" which knows where in the file you are, and each time you read from the file this advances so that you get the next piece of data each time you do a read. Usually you don't see the file pointer at all - it's internal - and you think nothing ...
1113File and URL reading in PHP
In PHP, we say "there's a function to do that" as the answer to almost any question is going to be in the form of a function name, or a list of functions, to call. And PHP has more functions than almost any other language, making it more flexible than most. Take file handling ... where in so many ...
1096Sample script - FTP to get a file from within PHP
A worked example from today's course - Only the password has been changed <?php $conn_id = ftp_connect("www.savethetrain.org.uk"); $login_result = ftp_login($conn_id, "savethetrain", "melksham"); if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; exit; } else ...
1094PHP fread - truncated data
Note that PHP's fread function returns the number of bytes you request as the second parameter ...OR the number of remaining bytes if it's less than the number you give ... or 8192 bytes, even if there's more than that available and you've requested more. I got caught out by this one earlier today ... ...
997Most recent file in a directory - PHP
Want to report the most recently updated file in a directory in PHP? It's the sort of thing we all want to do, but in a variety of modified forms, quite often ... here's a code snippet to do it for you: $dir = "/home/wellho/public_html/demo"; $pattern = '\.(html|php|php4)$'; $newstamp = 0; $newname ...
653Easy feed!
Want to provide sites that work close along side you with a feed of your blog? In recent versions of PHP, you can include a remote file from their server in your page. Here's a little example that's on our site - we're pulling down a piece of PHP via a URL. Want the latest news from Well House Consultants? ...
709Handling huge data files in PHP
I've handled files up to 2 GBytes in size with PHP ... but there are a number of issues to consider. 1. The size of the PHP "footprint" in memory - when you have a huge data file, you cannot simply read it all in with file or file_get_contents (nor with fread, trying to read the file all at once). Rather, ...
Examples from our training material
buslogic.inc   Business logic for quote demo
cloak.php   Cloaking a web site in a PHP wrapper
eurorates.php   Read currency exchanges rates
exchange.html   Automatic exchange rate conversion - collect today's exchange rate from European central Bank
fr2.php   Pulldown menu of files, then search for regex
fread1.php   Read all lines from a data file, report matches
fread2.php   File system and status reports and directory listings
grabtitle.php   Grab the title of a web page (local or remote)
mail_analysis.php   Read and analyse spam report file
mcq.txt   data for Christmas Quiz
quote.htp   HTML template for quote demo
quote.php   Quote demo - top level code
radio.php   look up current radio program in a text file
recent.php   Link to the recently updated file in a directory
savepeople.php   Using PHP to download a data file
saver.php   Write to file - simple diary page
secdo.php   Convert seconds to minutes and seconds
seedoku.php   highlighting a source file
spammiest.php   The 20 spammiest emails in our filter records are ...
timber.php   Reading and extracting from a remote URL
top_pdf.php   Showing top 10 downloads from our site
webhelpers.inc   Web Helpers for quote demo
xmasq.php   Christmas Quiz in PHP
PHP Programming course
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Opening access to files on the server.
Reading from and writing to files.
File and directory functions.
Include and require.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/H109.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat