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))
Clean my plate, but keep my wine bottle. (PHP; Static)

On Monday morning, I served Colin's breakfast on a clean plate in the "Whitworth" ... one happy camper, judging by the crumbs and butter wrappers left on the plate, and the smile on Colin's face.

Never wanting to disturb a customer's property and space, I carefully preserved the plate as Colin left it on that morning and returned the plate to him, in that same crumby condition, on Tuesday morning. But Colin didn't appreciate the care I had taken to preserve his crumbs and would have much preferred a clean start.

On Wednesday, I'll make sure he has a clean, pristine new plate!

When you call a function in PHP, the internal variables within that function are freshly re-initialised each time. There is no debris left over from previous operations. And that's a good and sensible default - just like Colin on Tuesday and Wednesday morning, you don't want to be reminded about what happened on Monday.




Colin drank a glass of wine out of a bottle he brought with him on Tuesday night, and came looking for it to have another glass on Wednesday night. He was a little unhappy that we had cleaned up and thrown out his undrunk wine, even though he had requested a clean breakfast plate each morning. This is an exception to the "clean up fully every time" rule ... and in PHP terms, you would declare a variable within the function to be static to ensure that its value is held from one call to the next.
(written 2007-09-18)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
H105 - PHP - Functions
  [96] Variable Scope - (2004-10-22)
  [223] There is a function in PHP to do that - (2005-02-21)
  [308] Call by name v call by value - (2005-05-11)
  [339] Passing information into and out of PHP functions - (2005-06-07)
  [340] Code and code maintainance efficiency - (2005-06-08)
  [409] Functions and commands with dangerous names - (2005-08-11)
  [421] Don't repeat code - use loops or functions - (2005-08-21)
  [775] Do not duplicate your code - (2006-06-23)
  [866] A lazy programmer is a good programmer - (2006-09-15)
  [936] Global, Superglobal, Session variables - scope and persistance in PHP - (2006-11-21)
  [1021] PHP - static declaration - (2007-01-04)
  [1163] A better alternative to cutting and pasting code - (2007-04-26)
  [1202] Returning multiple values from a function (Perl, PHP, Python) - (2007-05-24)
  [1267] is there a lookup function in php? - (2007-07-15)
  [1380] Static variables in PHP - (2007-10-05)
  [1784] Global - Tcl, PHP, Python - (2008-09-03)
  [2488] A variable number of arguments in a PHP function - (2009-11-02)
  [2630] Static variables and ampersands in PHP - (2010-02-10)
  [2682] Adding extensions to PHP Open Source applications - callbacks - (2010-03-17)
  [2737] Improving your function calls (APIs) - General and PHP - (2010-04-24)
  [2929] Passing a variable number of parameters in to a function / method - (2010-08-20)
  [3026] Coding efficiency - do not repeat yourself! - (2010-11-02)


Back to
Crystal Ball - How long do I need to be online?
Previous and next
or
Horse's mouth home
Forward to
Look forward with a new broom - Wiltshire Train Service
Some other Articles
Korn shell course
Asda in Melksham - Welcome or not?
Little Gems but not Lettuce
Look forward with a new broom - Wiltshire Train Service
Clean my plate, but keep my wine bottle. (PHP; Static)
Crystal Ball - How long do I need to be online?
.php or .html extension? Morally Static Pages
Match the Bedroom to the Hotel
Mood shots
Actionscript / Flash / Flex (IAQ/FAQ)
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

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.net/mouth/1357_Cle ... atic-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb