 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Script-Tutorials.com: Phar - PHP archiving practice
by Chris Cornutt May 17, 2011 @ 08:28:50
On Script-Tutorials.com today there's a new tutorial showing you how to use one of the more under-used and powerful features of recent PHP releases - the phar packaging for creating self-contained archives.
I guess you noticed that due your project become larger - the more and more files it contain. Sometimes it comes to the thousands of files. And then - Phar can help you. This utility allows us to pack a variety of files in the single library file. Thus, we can significantly reduce the number of include files in the project, and work with the entire library as with single file. It is also possible to have a packed (gzip/bzip2) version of the library.
They show you how to create simple phar archive (sample code here) that contains a few classes linked by an index.php file.
voice your opinion now!
phar archive tutorial classes
Jani Hartikainen's Blog: How to use built-in SPL exception classes for better error handling
by Chris Cornutt May 09, 2011 @ 08:47:12
On his blog today Jani Hartikainen looks at how you can use the SPL exception types to allow for better overall error handling in your application. Things like BadMethodCallException and OutOfBoundsException make the errors much more descriptive.
Since PHP 5, there has been a bundle of built-in exceptions - the "SPL exceptions" - in PHP. However, the documentation for these classes is quite lacking in examples, and it can be difficult to understand when you should be using them. The short answer is always.
The list of exception types he recommends include:
- BadMethodCallException
- DomainException
- LengthException
- OutOfRangeException
- UnexpectedValueException
For each he gives an example usage of it, sometimes including a bit of code to illustrate.
voice your opinion now!
spl standardphplibrary exception handling classes types
NETTUTS.com: ASP.NET for PHP Developers Part 2
by Chris Cornutt February 19, 2010 @ 10:50:40
NETTUTS.com has posted the second part of their series looking to help PHP developers understand a bit more about the world of ASP.NET. This second part gets a bit more advanced than the first part.
It's been a hard climb for me, as a PHP guy for many years, to get to grips with ASP.NET. However I've found many good things in the framework, and have come to appreciate the power of the C# language - without losing my love for PHP.
He talks about using a development method he's come up with (rather than ASP.NET WebForms or ASP.NET MVC) because of his standards for the output, their reliance on Javascript and why he chose to learn the base .Net framework. He shows how to create a master page (template), work with custom classes, hook the script into databases and handling user controls.
voice your opinion now!
aspnet tutorial masterpage classes database usercontrol
Matthew Weir O'Phinney's Blog: PHP 5's Reflection API
by Chris Cornutt October 09, 2006 @ 13:37:00
In his latest blog post, Matthew Weir O'Phinney shares some of his newfound love for the Reflection API that PHP5 brings to the table:
When I first read about the Reflection API in a pre-PHP 5 changelog, my initial reaction was, "who cares?" I simply failed to see how it was a useful addition to the language. Having done some projects recently that needed to know something about the classes they are using, I now understand when and how it can be used.
It shines when you need to work with classes that may not be defined when you write your code -- any code that dispatches to other classes, basically.
To emphasize the point, he lists a few things you can do with the API, including determine if a method exists in a class and instantiate an object instance with a variable number of arguments to the constructor. He also includes a code example, showing a simple method of getting all of the methods on a class.
voice your opinion now!
relfection api php5 classes object method example relfection api php5 classes object method example
DevShed: Using Inheritance, Polymorphism and Serialization with PHP Classes
by Chris Cornutt August 15, 2006 @ 09:02:43
Some concepts of object-oriented design are harder to figure out that others for a budding programmer. Thankfully, there's articles like this one from DevShed to help fill in some of the gaps. Specifically, they focus on inheritance, polymorphism, and serialization in your PHP classes.
If you are working with classes in PHP, you will sooner or later encounter inheritance, polymorphism, and serialization. The ability to use these three will help speed up your code writing. This article covers how to use them, and more.
First off, they look at inheritance and working with child classes before moving on to polymorphism (similar functionality, different objects), calling functions statically, and serializing objects to make passing them around much easier.
voice your opinion now!
classes object oriented polymorphism inheritance serialization tutorial classes object oriented polymorphism inheritance serialization tutorial
DevShed: Classes as PHP Functions
by Chris Cornutt August 09, 2006 @ 05:49:25
Continuing on in their "PHP functions" series today, DevShed has posted this next step up the ladder, getting more advanced with the functions they're working with. This time, there's a focus on functions inside classes and creating the classes around them (a sort of introduction to object-oriented programming).
Continuing our PHP functions article, we move on to creating classes. Let me say right at the start that you can write perfectly effective and useful PHP code without creating classes or going into object oriented programming. Object oriented programming can be very powerful and PHP programmers are increasingly taking advantage of these capabilities, which have been greatly expanded since PHP4.
They start with the creation of a simple class - a human class with two $legs and two $arms. They show a simple display of this data and add another attribute to the class, one for hair color. They then capture the output they've been creating inside a function, report, and show how to execute it. Finally, they show how to use the special function that runs when the object is created - the constructor.
voice your opinion now!
classes functions methods properties tutorial part2 classes functions methods properties tutorial part2
DevShed: Overloading Classes in PHP 5
by Chris Cornutt July 26, 2006 @ 05:53:51
DevShed is wrapping up their "Overloading in PHP" series today with this last part - "Overloading Classes in PHP5".
It's time to move on and continue exploring the subject, since there are still a few additional topics that need to be covered. So, what's comes next now? All right, in this last part of the series, I'll be explaining how to overload classes specifically in PHP 5, which offers native support for overloading class members and methods, without having to explicitly call the PHP built-in "overload()" function.
They look first at using the __get method to replace __set in their previous code to save data out to a file. Then, to illustrate even more enhanced functionality, they implement __get and __set at the same time in a class, using them to grab values and set values to properties. Finally, they throw __call into the mix, showing how to overload method calls too.
voice your opinion now!
overloading part3 tutorial classes php5 get set call overloading part3 tutorial classes php5 get set call
|
Community Events
Don't see your event here? Let us know!
|