The Developer Day | Staying Curious

TAG | tips

Internet Explorer has a strange issue regarding http referers. If you would have a link and would follow that link $_SERVER['HTTP_REFERER'] value would get populated. But if a redirect is done using javascript like this:

top.location.href = 'page.php';

The HTTP_REFERER will not get value populated. I tried to figure out why is this happening but seems it’s just the way it is. All other browsers Firefox, Chrome, Opera will set the referer properly, but IE6, IE7 and IE8 will not.

Though it is not a good practice to rely on HTTP_REFERER and you should probably not use it if you can, but nevertheless such kind of behaviour may cause strange bugs. If you happen to know why Internet Explorer behaves like this or know workaround to still have a referer value set when the browser redirects using javascript please leave a comment.

, , , Hide



Exotic PHP data type tips and tricks

What do you think the output of this code snippet would be:

$array = array (0.1 => 'a', 0.2 => 'b');
echo count ($array);

It’s 1! In PHP array keys can only be made from integers and strings. Strangely enough it accepts floats too and casts them to integers!

While reviewing old code you might find stuf like:


Note that the $array is passed by reference. Yet again it turns out this kind of technique is deprecated and one should redeclare the function to accept the $array by reference. Common in PHP itself. Sadly I didn’t get a helpful warning that this type of technique is deprecated.

, , Hide



Javascript Radio Group Value Tip Using Prototype

A simple tip how to find out radio group value with prototype:

var value;
Form.getInputs(this.form, 'radio').each( function(input) { if (input.checked) { value = input.value }; });

, , , Hide



Javascript forms innerHTML issue

If you would do something like this while validating a form:

document.getElementById('your_form_id').innerHTML += 'any text';

Your form will get reseted and there’s nothing more to validate.

, , Hide

Find it!

Theme Design by