EHS Blog
Home  
 
 
  Previous 10 Posts
  - Komodo 101
  - Adding Fresh Blood to the Bleeding Edge of Web Development with Komodo 4.1.1
  - ActiveState Hackathon: Get Your Boss to Do This!
  - Google hack to instantly search for files
  - 10 JSP tag libraries no programmer should be without
  - Learning the JavaFX way of doing things
  - Using JavaFX Script for UI Declarations
  - Unicode support in JavaFX Script
  - Could you cut your development time in half?
  - Cookie Handling
   

 
Categories


Web Hosting
Website Design
PHP
Perl
JSP
   

 
Archives

No Records !!!
   
 

2 3 4 5 6 7 9 10 11 12 13 

 
In-Depth with CGI.pm - Creating Hidden Form Fields
at 2007-08-12 15:11:20

Hidden fields are incredibly simple and very useful for passing data in a form you might not want your end user seeing. It is handy for passing ugly data...

Downloading YouTube videos with a Perl one-liner
at 2007-08-12 15:11:20

Here's a really cool tutorial on digging around in YouTube and grabbing a video with a line (well, 5 lines) of Perl code. A great article from Peteris Krumins. Downloading YouTube...

Shuffling methods
at 2007-08-12 15:10:22

I’m writing some quite complicated class structure in PHP, and I have realised there’s one feature I am missing in PHP - I need to be able to define an interface with default method implementation. Why not class? But of course because I can not inherit two classes. And I don’t really want multiple inheritance with all its problems - I want something much more restricted. Let’s see an example.

Let’s say I am definining interface “Kickable” having method kickMe, which describes an object that can be kicked. Most of the kickable classes would have this wonderful code:

function kickMe() {
    echo “Oy-vey!”;
}
?>

So if I have 20 classes which are kickable, I’d pr



dirname(__FILE__)
at 2007-08-12 15:10:22

This expression - dirname(__FILE__) - is used in a real lot of places. The reason is simple - libraries want to include files relative to library top directory, and do not want to count on include path. And relative include resolution rules in PHP not clear to all, so people prefer to be sure. The downside here is that this expression is dynamic - executed at run-time. Meaning it’s slower and less toolable and also makes a bad habit of putting dynamic things into include (which is not a problem here, since it’s “static dynamic” thing, but still a bad habit).

So why won’t we have constant that would mean dirname(__FILE__)? Something like __FILEDIR__. Would make a lot of code cleaner.

The problem with it of course to make real use in code we should travel back in time to 1996 and add it there :)



static __call
at 2007-08-12 15:10:22

As everybody knows, one of very nice OO features PHP 5 has is - if method that is not defined is called on an object of a class, the class could define catch-all method named __call and thus route this method call in any way the developer wants, transparent to the user. This allows very flexible way of defining interfaces between classes - even between entities that their interface might be not known to the developer of the class, such as SOAP services. Very useful indeed.

However, we can not do this on a class itself - we couldn’t define static __call and have it route class (static) method calls the same way regular __call routes the object method calls. I wonder maybe we should have it. Along with all other __methods for overloading stuff, of course. We couldn’t probably name it __call since we already have one call but something like



 

2 3 4 5 6 7 9 10 11 12 13 


Check Out Amazon