DevShed: The Switch Statement and Arrays
449459
DevShed continues their series looking at some of the fundamentals of working with PHP in this new tutorial posted today. It looks at one of the flow control statements the language has to offer and a very useful data structure - the switch statement and arrays.   In our last exciting adventure (back in early November), we braved crocodiles, ravenous editors, most of the PHP statements, and beginning loops. In this edition we'll cover the final statement, the Switch, and discuss arrays. So sit back, order your R2D2 robot to bring you a cold, frosty Jolt Cola, and let's get cracking.   They start with a simple example of a switch statement (to echo out strings) and follow it with a detailed description of the different sorts of arrays - numeric indexed, associative and multidimensional versions.
653298
In the last part of this series, you'll learn how to build a declarative component for an application with a list of customers which is populated from a server-side data handler using AJAX. By David Johnson, Alexei White, and Andre Charland. 0910
302538
Devshed continues their series looking at the use of destructors in PHP5 applications with part three, a method for keeping track of objects you've created during execution.   In this third part of the series, I'm going to show you how to retrieve some useful information about a specific object, including its properties and methods, prior to its being destroyed by the PHP parser via the implementation of a simple destructor.   Their new user class extracts the details about each of the objects right before they're destroyed via a call to get_object_vars and a loop to display the property and its value.
632739
Continuing on from this previous post, DevShed has this new tutorial posted. Another excerpt from O'Reilly's "Programming PHP, Second Edition" (by Kevin Tatroe, Rasmus Lerdorf, and Peter MacIntyre), this section gets more into connecting to the database, making a query and returning some information.   They start off looking at the DSNs mentioned previously and include a bit of error checking around it to handle anything that might come up. The next step is, of course, to make a query against the information in your database. They also include an example of the fetchRow method to push the returned results into a variable.   The variable is built out as an array, so they show what that array looks like "on the inside" and how you can reference the different values that make it up.
339394
DevShed continues its look at the DirectoryIterator functionality in PHP5 with the second part of the series today - "Finding Paths, Timestamps and More with the DirectoryIterator Class in PHP".   Are you interested in having at your disposal a quick reference for working with the "DirectoryIterator" class that comes with PHP 5? Then this might be the article that you've been waiting for! Welcome to the second tutorial of the series "A Close Look at the DirectoryIterator Class in PHP 5." Over the course of this set of installments, you'll find complete coverage of the most important methods bundled with this class, and learn how to take advantage of their excellent functionality.   They cover even more functions in this part:  rewind, current, valid getFileName, isFile getMTime, getATime, getCTime getPath, getPathName  Each set is supported by code and explaination to help introduce their concepts in a useful way.
467808
Devshed has posted a new article covering one of the hottest topics in the PHP community right now - security.   Security in a scripting language such as PHP is more developer-dependent than language-dependent. In other words, although the language offers you the tools to create secure code, it cannot prevent insecure code. Thus, the degree to which code is secure almost entirely depends on how security conscious a developer is.   The article looks at three security-related topics:  Register globals error reporting code exposure  and for each provides explanation and code where needed to help the reader understand the issues and possible problems with them.
218468
DevShed has posted the final installment of their series looking at the creation and use of the Abstract Factory pattern. In this new part, they focus on the creation of online forms and their handling as the pattern is applied.   In this last installment of the series, I'm going to show you how to use an abstract factory class to create distinct types of form objects, logically depending on the context where they will be utilized. The idea not only sounds interesting, but it can provide you with a better understanding of how this handy pattern can be used in a real situation.   They start by defining their abstract factory form class and extending it to create a required form element and a normal form element. They make input functions for each - required input box, required radio button, required check box - and their "Normal" counterparts. Finally, they tie these all together to create a simple form with sets of an input box, radio set, and checkboxes both required and normal.
716986
In his latest blog entry, Brian Moon takes a look at using big arrays in PHP - how efficient it is and what can be done to ease things a bit.   So, at dealnews, we have a category tree. To make life easy, we dump it to an array in a file that we can include on any page. It has 420 entries. So, I was curious how efficient this was. I noticed that some code that was using this array was jumping in memory usage as soon as I ran the script.   His tests showed that the memory jump from before and after the array was significant (5 MB for his test). He tested different methods of storage for the array including a var_export and serializing the data (the lowest memory option).
582158
Michael Kimsal points out the posting of the latest part of his "Grails for PHP developers" series to his blog site - Part Five of the series.   I've put up the latest installment in my "Grails for PHP developers".  Rather than delve too much more in to Grails head on, I'm taking this installment (and at least the next one) to delve more in to the Groovy language itself.  Groovy offers similarities to PHP, but also many differences which can trip you up if you're not careful.  I'll try to lay those out as best I can in the next couple of installments.   This new part of the series goes back and puts the spotlight on GRoovy, the base of the Groovy/Grails combo. He talks about working with variables and arrays as containers for multiple pieces of data and some possible gotchas that could come up along the way.
445025
Popular posts from PHPDeveloper.org for the past week:Stijn Leenknegt's Blog: [PHP6] function-return-array idea!GeesNotNerds Blog: Free PHP + Ajax chat appStefan Mischook's Blog: Object Oriented PHP Tutorial Updated - Steps 18 - 22Dave Dash's Blog: SymfonyCampWebDigity.com: PHP geotargeting techniquesEtienne Kneuss' Blog: Late Static Bindings ExplainedDevShed: Handling Static Data with PHP 5PHP-Learn-It.com: Cooking Cookies with PHPMichael Kimsal's Blog: PHP PredictionJob Posting: Steinman Recruiting Seeks Senior Developer (Littleton, CO)
217574
As mentioned by Ed Finkler, there's a list of signs your PHP needs refactoring from Soledad Penades.    I have had to go through a php application recently which has given me more than one headache and has required me to use all my possible patience. While working with it, I thought This is good material for an article, so that nobody else does the same in the future, and nobody else will need to experience the same displeasure as I have had to.   So here are the signs your PHP application needs a serious refactoring, right now    Included in the list are things like:   Uses global variables Everything's an array The neverending switch Interface inconsistency   It hits on one of the thing that bugs me too, the problem of "Brackets galore" - so many subarrays that you have to resort to three or more sets of bracketed keys to get to the value you want. It's bad enough trying to follow someone else's code without having to "trace down" an array to figure out which of the values they're talking about.
396172
Alexey Zakhlestin gave a talk for the PHPThinktank IRC channel recently on the topic of YAML, PHP, and some of the work that he's done combining the two.   It happened a bit of spontaneously, so noone was invited. It was my first try, to make introduction to yaml for php prgrammers, and if there is more interest I will give another talk which will cover more details, this time with proper scheduling :)   You can check out the log of the discussion for his entire talk (covering topics like what YAML is, where to get more information on it, some of its features, and a mention of the Syck library for parsing it).
710741
Bridge to controversy IDF Intel's tradition of issuing confusing and innocuous processor code-names has been derailed. Oh, the code-names are still confusing because of their quantity, but they've shifted from innocuous to loaded.â¦
660553
DevShed continues their series looking at connecting a PHP5 script to the powerful Yahoo! search backend with part four of the series today. This part focuses on reworking some of the previous examples to make them more modular using custom defined functions.   Logically, these examples can be really useful for learning the basic concepts surrounding the use of these search services, but undoubtedly, it's necessary to modify and improve their source code to make it more compact and completely reusable.   They start the overhaul with the web search (complete with example results) then push on to the video and image searches and work them over the same way.
759924
Chris Hartjes is taking on what he calls his "next foolish project" - a console for the CakePHP framework.   On the CakePHP mailing list, somebody familiar with Ruby on Rails' console functionality asked "why isn't there one of these in Cake?" [...] So I got to thinking about how to do this. On the surface, it seems the easiest way to do this is to write a PHP script that takes entries on the command line, run the input through an 'eval' statement. Sounds easy enough, and I could write that in a hurry. I think the trickiness comes in figuring out how to hook it into CakePHP so that you can access Models that already exist.   For those attending the Vancouver PHP Conference, attend his talk and you might get  amention of how far he's come with the idea. Otherwise, stay tuned to his blog for updates.
449834
Sebastian Bergmann has posted the results of some benchmarking on the compilation he's done on the branches of PHP from version 3.0 all the way up to 5.3-CVS.   As people keep asking me for an update to my previous benchmarks (PHP / GCC / ICC Benchmark, PHP 5.1 / GCC Benchmark (Update), and PHP 5.1 Performance, I quickly ran a new benchmark today.   He rendered the results out into a series of charts defining the number of total seconds taken for the compile and how long each of the components took. It's impressive to see how much of a jump there was between the 3.0 series and 4.3.   He also includes his compile settings (and machine information) as well as the numbers for the results if you'd like to graph them out yourself.
192641
DevShed has posted the second and last part of a series of two articles based around the Composite design pattern - using it to work with strings in PHP5.   Are you a PHP developer who wants to improve your skills in pattern-based programming in PHP? If the answer to this question is a emphatic yes, then you should begin reading this article now! Welcome to the final part of the series "Implementing the composite pattern with PHP 5." Comprised of two instructive tutorials, this series walks you through the basic concepts of this important design pattern, and shows you how to apply it with some educational examples.   They start by defining a simple StringProcessor class as an abstract interface to build from. From there, they create two other classes - the SingleStringProcessor and the MultipleStringProcessor. Each of these takes in either a single file or multiple filenames and spits back out the value of the string and the length of the string.