For 2023 - 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 subject | updated | 4483 | Moving 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 ... | 2015-05-03 | 3424 | Divide 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 ... | 2011-09-08 | 3159 | Returning 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 ... | 2011-02-10 | 3029 | PHP 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 ... | 2010-11-04 | 2964 | An 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 ... | 2010-09-21 (longer) | 1780 | Server 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 ... | 2008-09-01 | 1442 | Reading 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 ... | 2007-11-27 | 1113 | File 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 ... | 2007-03-21 | 1096 | Sample 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 ... | 2007-03-01 | 1094 | PHP 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 ... ... | 2007-02-28 (short) | 997 | Most 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 ... | 2006-12-21 | 114 | Relative 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 ... | 2006-06-05 | 709 | Handling 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, ... | 2006-05-04 |
Examples from our training material
Pictures 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.
|
|
|