Category Archives: The Know Your Language Department

Using Assertions with (Legacy) PHP Code

While it was not much advised to use assertions (the assert PHP language construct) prior to PHP 7 due to the fact that it actually eval’ed a string’ed code, these days are gone. This is probably a lesser known fact with … Continue reading

Posted in Developing, Hakre's Tips, PHP Development, PHP Development, Pressed, The Know Your Language Department, Tools | Tagged , , , , , , , | Leave a comment

Lazy Loading in PHP Object Composition

When it comes to nicely performing PHP scripts (yes in PHP these are all scripts as PHP code is run-time) there is a nice addition since PHP 7 named the Null coalescing operator which plays very well with the basic nature … Continue reading

Posted in Hakre's Tips, PHP Development, PHP Development, Pressed, The Know Your Language Department, Tools | Tagged , | Leave a comment

History of the PHP date timezone settings warning

Now with the newborn elefant PHP 7 in the herd, there is a lift on the date timezone settings warning: it has just been removed. That means, it’s now that you need to take care in the server’s configuration that … Continue reading

Posted in Pressed, The Know Your Language Department | Tagged , , , | Leave a comment

The SimpleXMLElement Magic Wonder World in PHP

PHP’s Simplexml ships with a lot of magic to simplify access to an XML documents element and attribute node values. Some criticize this and suggest to use the DOM library instead. The DOM library on the other hand, even it … Continue reading

Posted in Developing, Hakre's Tips, PHP Development, Pressed, The Know Your Language Department, Uncategorized | Tagged , , , , | Leave a comment

PHP turtles – Turtles all the way down

Some nice line-up for the know your language department: PHP turtles – Turtles all the way down.

Posted in Linked, PHP Development, Pressed, The Know Your Language Department | Tagged | Leave a comment

The Greatest PHP Value

Just two days ago I asked a PHP-quiz-question in the chatroom on Stackoverflow, something along the lines: PHP: Which one is greatest? PHP has a comparison operator to compare if one value is greater than the other (>). Which one … Continue reading

Posted in Developing, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , | Leave a comment

Late Static Bindings in PHP Callbacks

No idea if this is ever useful, but just found this not documented in the PHP manual so far (and the Callbacks entry looks already chaotic so I don’t edit it right now): You can write callbacks of static class … Continue reading

Posted in PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , , , , , , , | 1 Comment

SimpleXML Type Cheatsheet

A SimpleXMLElement can represent many different things, from an element, to a list of attributes or childelements. Sometimes it’s good to know how to find out, especially with the magic the extension comes with. The following is a table with … Continue reading

Posted in Hakre's Tips, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , , , , , | 1 Comment

PHP Autoload Invalid Classname Injection

There are many ways to attack an application, many are working by injecting some malicious data hoping to trigger a deserved action in the end. Most of these are possible when input data is not properly sanitized. This can have … Continue reading

Posted in Features, Hakre's Tips, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , , | 1 Comment

PHP MVC with Tom Butler

In the PHP chat a link got passed around (see “Deploying MVC on the web” below) and I thought it’s worth to link the multiple MVC related articles by Tom Butler. He is one of those persons who actually leave … Continue reading

Posted in Linked, PHP Development, Pressed, The Know Your Language Department | Tagged , , , , | 1 Comment

PHP UTF-8 String Length

If you’ve got an UTF-8 encoded PHP string (e.g. when working with DOMDocument) and you don’t want to rely on the mbstring extension to get it’s length, this can be solved with a simple regular expression (as the string does … Continue reading

Posted in PHP Development, PHP Library, Pressed, The Know Your Language Department | Tagged , , , , , , , , | 1 Comment

Improved handling of HTTP requests in PHP

Improved handling of HTTP requests in PHP Merci beaucoup Nicolas Grekas for compiling this in-depth! Read On: getallheaders available for FASTCGI in PHP 5.4 (18 Jul 2011)

Posted in Linked, PHP Development, The Know Your Language Department | Tagged , , , | 1 Comment

Don’t tell nobody!: class IntegerstringArray IMPLEMENTS ArrayAccess

Posted on by hakre | Leave a comment

Protocol of some PHP Memory Stretching Fun

The know your language department was having a day out with the gang from the know your runtime department. The topic of today was to play with the PHP memory limit, let’s grab the laptop’s shell: $ php -d memory_limit=1g … Continue reading

Posted in PHP Development, Pressed, Reports, The Know Your Language Department, Uncategorized | Tagged , , , , , | Leave a comment

PHP: Empty() is the Opposite of a Boolean Variable

From the know your language department: It’s already written in the PHP manual, if we could only read it 😉 : empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set. … Continue reading

Posted in PHP Development, Pressed, The Know Your Language Department | Tagged , , | 3 Comments

PHP: is_null() vs. NULL ===

From the know your language department: If you can, go with the identical comparison operator ===. That’s a good approach in PHP for various reasons. Only one example: could be written as: but it is about more than 14 times … Continue reading

Posted in PHP Development, Pressed, The Know Your Language Department | Tagged , , , | 7 Comments

PHP: Casting vs. intval()

Doing a cast like (int) $var instead of the intval($var) function is about 300% to 650% faster. I did some tests out of curiousity in #13317 and those are the results:

Posted in Hacking The Core, Pressed, The Know Your Language Department | Tagged , , , , , , , , | 19 Comments

End.

Finally I come to an end: The good thing about reading source-code written by others is that you can learn something. That can be things to do or to prevent. And sometimes you find something new. I did this week, … Continue reading

Posted in Pressed, The Know Your Language Department | Tagged | Leave a comment