Posts Tagged ‘PHP’

APC.php

Sunday, June 6th, 2010

if you google for “apc.php?SCOPE” you get 202.000 hits. I opened at random (more or less) 10 of those. All giving a shitload of information about the host and file structure.

Seems pretty unsafe for me to have that information stored in Google.

Memcache(d)

Thursday, June 3rd, 2010

Recently I started (finally) with implementing caches for our php projects. I extended the database class with additional query methods utilizing memcache.

While writing some unittests, i was confused by the documentation of php regarding memcache.
I always wondered why there was a pecl/memcache and a pecl/memcached. I assumed one was the client API, the other the server API (or something similar).

BEEEP! WRONG!

Seems that both are libraries providing methods for accessing the memcached (memcache daemon).

You have to choose one! or… use them both… but have to be very aware which one you are using :)

I have chosen to use memcached. Primarly because it’s only a wrapper to libmemcached (which is a big plus in my eyes).

duh :)

Tuesday, March 9th, 2010

Someone on chat asked me what switches he had to use to execute php on the command-line. He tried to execute a php script, and all the command returned was the contents of the script, instead of executing it.

At least… that was what he claimed. I don’t use php on the cli a lot, so just to be sure i wrote a quick test script, which executed flawless.

So I took a look at the script he tried to execute:

echo html_entities_decode(file_get_contents($argv[0]));

So the script did exactly what was asked ;) outputting the content of the script itself, instead of outputting the content of the file given as 1st argument to the script.

hi hi.
He overlooked the fact that the 0-key of the argv array holds the name of the script itself, instead of the 1st argument given on the cli :)

Thoughts on the take over of MySQL AB by Sun.

Thursday, January 17th, 2008

The buzz in the blogosphere yesterday could hardly be missed. MySQL AB and Sun Microsystems announced they reached a final agreement for the acquisition of MySQL AB by Sun Microsystems. First of all, I think that it is very important that there is a difference between MySQL AB (the company) and MySQL the open source Database engine.
MySQL doesn’t “own” MySQL. Mysql is an open source project, so the source is free to modify and use etc according to the GPL license.

The people of MySQL AB seem to be very happy with the take-over. I can imagine that. It will give for sure some financial ease of mind for the company and his employees and access to a large source of knowledge and resources. Somehow many people, including myself, have a suspicion against “the big corporations”. With the exception of Apple computers ofc :).
Don’t forget however that Sun has a decent and reliable history with Open Source. Open Office and making Java open source to name 2 big achievements of Sun.
I use MySQL now for close to 9 years. I have learned to love this database engine, discovering the more advanced features of SQL step by step. I only have used MySQL directly or interfaced by PHP.
I can only express my hope that Sun will support the continuous development of the MySQL API as used by the MySQLi or mysqlnd extensions of PHP.
Some analysts suspect that Sun is busy to build his “own” alternative to the classic LAMP (Linux, Apache, MySQL, PHP) stack. The Sun-Stack would be SAMJ (Solaris (opensourced!), Apache, MySQL, Java).
People should have the freedom to use and code the language they prefer.
I really hope it won’t be soon that if you want to have the full support for the capabilities of MySQL, you have to use a Java interface to interact with the database engine from a web-environment.

OOP programming for webapplications usefull?

Wednesday, August 31st, 2005

While coding (php5) on a new project today, I found myself struggling with the question to fit a collection of functions in a class or not. Or in other words, to maintain a procedural style, or more object orientated.
I only learned recently how to use objects and classes in php5 and I find myself mixing objects and procedural style within scripts. For instance, html templates and database abstraction is fitted in classes, while handling a form (collection -> validating ->processing) is done in a procedural style in my scripts.

I think that webapplication-coding is by nature more suitable for a procedural style. You have a very clear starting point and end. So the timeline in your script is very linear. Compare this with java, where applets mostly run in a loop waiting for userevents. The fundamental difference in nature (begin->end against looping) explains my struggle to code completely OOP with PHP.

Off course OOP has lots of advantages with PHP (execption handling, code reusability to name a few) but I think when coding webapplications, you will always find yourself coding a more or less procedural timeline within your script.