For the first time in a while I’ve actually been terrified of a film. I just watched [rec] with Hannah, and it’s absolutely scary. To the point I was sweating and jumping. It’s got extreme amounts of suspense, and it’s one of the few films where I wasn’t sure how it was going to end. It had me curled up in a ball on the sofa, squeezing Hannah’s hand! I very highly recommend this to any horror fan, but if you get scared easily, don’t watch this film.
Apr 18 2008
I found an interesting helper function today through the PHPDeveloper.org feed.
It’s as simple as the topic suggests - it’s a function that takes an XML formatted string and returns an array containing the results. Using the example from Michael’s msbware.com:
Example source XML:
<xmlData> <author> <name>John Doe</name> <magazine>Time</magazine> <magazine>National Geographic</magazine> </author> </xmlData>
Example result array with:
[xmlData][author][name] => John Doe [xmlData][author][magazine][0] => Time [xmlData][author][magazine][1] => National Geographic
Apr 18 2008
Before you read this, I want to make one thing clear - I am not obsessive-compulsive. But some things annoy me about neat programming sometimes. Sometimes I just write new code that is neatly tabbed and aligned the way I like it. Other times I look at the old code that is around my new code. I turn on hidden characters and gasp at the spaces instead of tabs, and the whitespace at the end of most lines.
Leaving trailing whitespace is one thing, but not adhering to the project’s indentation scheme is another. Here at Netbasic, we use the TAB character to indent, not SPACE like some UNIX programs. Personally I prefer tab, as it’s neat, and you can adjust how wide each tab is in most editors, so you can lay your code out as indented or un-indented as you like. One feature I liked in UltraEdit though is the ability to remove trailing whitespace in a file. As far as I can tell, PhpED (although my new favourite editor) doesn’t have this feature.
Apr 17 2008
Prompted by PHPDeveloper.org’s RSS feed, I found this article about Screen capture with PHP and GD by Pierre. Might be interesting to play around with…
Apr 17 2008
I discovered the strange error of “syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM” today. Strange error, it’s been written about before, but to remind myself in future, it means “Double Colon” in Hebrew. The “T” is as normal meaning “Token”.
This also led me to talk to Kelvin about a way about my problem. I had a function something like this (I’ve re-written it as obviously I can’t directly post our company’s source code on the internet!!):
<?php function SomeFunction($className) { $result = $className::StaticMemberFunction(); } ?>
So if you try this you’ll find that it yields the afformentioned double colon error. It’s not possible to use the :: on a variable name, it must be on a class name. Kelvin told me there’s a couple of solutions, one safe, one unsafe.
The unsafe one is to build PHP code as a string using the get_class_name on $className to statically call StaticMemberFunction(), and eval() that string. eval(), of course is unsafe and absolute care and attention needs to be made to insuring against code injection, something that could be potentially dangerous.
The safer and much easier method is to just instatiate the class. Static functions don’t have to be called statically, it’s just sometimes easier to not have to create an instance of the class just to call a function if it doesn’t access member variables. Unfortunately in this case, where we don’t know what class we’re calling, we have to do it this way, so this will work:
<?php function SomeFunction($className) { $class_instance = new $className(); $result = $class_instance->StaticMemberFunction(); } ?>
Yay it works!


