News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Script-Tutorials.com:
Phar - PHP archiving practice
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.

0 comments voice your opinion now!
phar archive tutorial classes


Jani Hartikainen's Blog:
How to use built-in SPL exception classes for better error handling
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.

0 comments voice your opinion now!
spl standardphplibrary exception handling classes types


NETTUTS.com:
ASP.NET for PHP Developers Part 2
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.

0 comments voice your opinion now!
aspnet tutorial masterpage classes database usercontrol


PHPImpact Blog:
30 Useful PHP Classes and Components
May 30, 2008 @ 10:23:52

The PHP::Impact blog has posted a list of thirty classes and components that can make your PHP development life so much easier:

Simplicity and extensibility are the main reasons why PHP became the favourite dynamic language of the Web. In the last decade, PHP has developed from a niche language for adding dynamic functionality to small websites to a powerful tool making strong inroads into large-scale Web systems.

Their list includes software like:

...and many more. Check out the full list for all sorts of useful tools.

0 comments voice your opinion now!
classes component project list simple help


Stefan Mischook's Blog:
A Question about object properties in PHP Classes
December 07, 2007 @ 14:33:00

Stefan Mischook shares a little question and answer he had recently concerning object properties in PHP.

The question asked about accessing properties outside the class and/or defining them as protected/private to prevent it. Stefan's response was basically:

Many OO techniques are designed for situations where you will have more than one programmer involved, now or later. By declaring variables as protected or private, you are adding security to the code base by forcing the use of getter and setter methods where you can control how objects are used.
0 comments voice your opinion now!
properties classes object private protected properties classes object private protected


Matthew Weir O'Phinney's Blog:
PHP 5's Reflection API
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.

0 comments 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
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.

0 comments voice your opinion now!
classes object oriented polymorphism inheritance serialization tutorial classes object oriented polymorphism inheritance serialization tutorial


Jacob Santos's Blog:
Don't Advocate Inner Classes
August 11, 2006 @ 07:38:43

Jacob Santos talks in this new blog post about something that, if added to PHP, just might be more trouble than it's worth - inner classes.

Inner Classes are contained in parent classes and offer a sort of namespace mechanism for the public and open private class data transfer for private subclasses.

The functionality is already available in other languages, but the question is whether it is needed in PHP. The short answer is no. With PHP execution model, it would further slow down and bloat PHP compilation.

He demonstrates their purpose with some simple examples but also gives the reasons why it would be a bad thing to try to include them, including the better choice of namespaces over inner classes.

0 comments voice your opinion now!
inner classes advocate purpose namespaces choice inner classes advocate purpose namespaces choice


DevShed:
Classes as PHP Functions
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.

0 comments voice your opinion now!
classes functions methods properties tutorial part2 classes functions methods properties tutorial part2


DevShed:
Overloading Classes in PHP 5
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.

0 comments 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!


community application configure introduction list release podcast language series bugfix threedevsandamaybe code framework wordpress developer library api laravel interview project

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework