Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

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 ...
114Relative or absolute milkman
Rather contrary to current trends, we've just started taking regular deliveries of milk (+ bread + eggs) at our training centre from the local milkman. As we grow busier, it's more effective to have someone deliver to us as part of his round rather than having to make a special trip out. And our "mint ...
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
Input from a file.
Checking a file and looking around.
Example of output to a file.
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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/resources/H109.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb