Difference between $_XXX and $HTTP_XXX_VARS

Almost every PHP developer is familiar with $_POST and $HTTP_POST_VARS arrays. Can you tell any significant difference between them? Well, you may think that there is no difference except that the former one was supported after PHP 4.1.0. But the truth is they have one very significant difference between them.

$_POST is a superglobal array and it is also known as an autoglobal array. That makes it available under any scope. Whether you are calling them inside a class, or function you need to declare it as global $_POST.

The $HTTP_POST_VARS is not a superglobal array in truth. If you want to access it inside any function, you must declare it as global. Otherwise it will be considered as a normal array in current function scope which is not what you actually want.

$HTTP_POST_VARS will not be considered as a superglobal array until register_global is turned on.

The same difference exists between their peers like $_GET and $HTTP_GET_VARS, $_FILES and $HTTP_POST_FILES, $_COOKIE and $HTTP_COOKIE_VARS, $_SESSION and $HTTP_SESSION_VARS.

If you are not aware of these difference, you script may fall into severe compatibility problem and you may spend many hours to debug it.

Update June 8th

I am ow in Bogra for the Akika of my son, Afif. It is great to be with family members again. I am enjoying my time here in my hometown.

As I already passed ZCE, Now I ama bit free. I am writing my next book on WordPress and It will be published by the endof this year. Beside this, I have to work in JavaFrameworks from this saturday, after a 3-week long vacation.

These days I am pretty interested to learn Ruby. Matz made this language an extra ordinarily cryptic, but short. I can do a lot of things with small statements, though the syntax is pretty mystic. I am not familiar with that type of syntax.

I am also planning to extend zephyr, my Open source ajax MVC framework and make a stable release by the end of next month. I already start working on it.

I am very happy these days. I got my two dreams fulfilled by a short interval. I became father and I became ZCE. Thanks Allah for giving me so much.

Finally – I am the first Zend Certified Engineer from Bangladesh

Well, after dreaming for more than one year and preparing for last couple of weeks, I have passed the Zend PHP Certification exam yesterday. The exam was much tough than I thought and prepared for. Most of all, many questions seem confusing. It seems that all answers are correct – but the truth is only “one”.

When I start the exam – I was pretty nervous. I got a lot of questions checking the syntactical skills. Some questions were from Regular Expressions and Some for Dates. The syntactical questions were more confusing than others.

Before starting the exam we have to agree with a NDA (Non Disclosure Agreement) that we will not disclose any question after exam. So it is not possible to tell any questions here. But just believe me – It is much tough for you if you just study the practice guide and study guide. It requires real life programming skills.

By the way – I am very happy with the result. Though the score is not disclosed so you get the grade “Passed” or “Failed”. If the score were disclosed, it would be better for every developer who has taken the exam.

I am blessed by god with a beautiful gift

Last week, I had been father of a beautiful young son, Afif Mohiuddin. We were waiting for him for the last 40 weeks. While my wife was in OT, I was simply dyeing out of tension. We didn’t even know whether a boy or girl is coming, before he born. So it was a great moment for us.

Afif weighs around 6 lb. He is tall – Hope he will be as tall as me.

We are passing a good time with Afif. Welcome to the Mother Earth, dear son.

Afif Mohiuddin

Update 17th May : Bangla Computing

Heres come another birthday in somewherein. Now its T-poo’s time. Happy Birsth Day Dear T-poo.

Last two days I was working for Bangla Blog. Almost everything was done except “English”. Today I just finish the code, now users can write in english as well as in bangla. So far in the history, this is the first full fledged Bangla Forum in internet.

Oh, these things make me nostalgic. I remember the night before my Sisth Semester “Flood Mitigation” exam, How I was planning to make a “Bangla Emailing Service”. Emran bhai and me spent a lot of time in planning the system.

I am working for bangla computing for a long long time, since my 3rd semester in RUET. First I developed a phonetic parser that works with MS Word. When Daffodil bough the source code, it ispired us a lot. After that I started working for a E2B translator as a thesis project of one of my senior brother. That translator can translate simple sentences, from nine types of tense. Later I start working for Bangla Emalier and Bangla Dictionary. From System I developed both system and most surprisingly, BanglaExpress is the largest bangla emailing solution in the world.

When I was introduced with Dr. Shah Musa, chip design architect in Intel Corporation, he explored his dream in a new style of bangla computing called “Nobobangla“. I worked in that project for more than one year. I was the lead developer for that project. I am still involved with that project.

I have also spent a lot of time to develop an open source bangla keyboard manager, Srishty. This is totally unicode based and works pretty fine in all Windows Applications.

Finally I have spent a lot of times developing Bangla Blog, with Emran. Emran is a nice man whom I like very much. He is a genius. During this time I developed the first phonetic parser script for Bangla in web applications. Users can transliterally input english to write bangla. And last but not least, I developed this Bangla Forum.

I really enjoy working with these RnD projects.

Using Firefox 2.0 – "Bon Echo"

Well, from one of my favorite blog “Cow at NeonDragon” I came to know about this new release of mozilla firefox. It’s surprising that mozilla is releasing new versions of their firefox in a new name “Bon Echo”. The name is not appealing as its previous sibling. After reading his post I decide to download the current version of Bon Echo,which is still in alpha phase, and test it. I found it is much more user friendly than its siblings. There are also some cool features.

1. In every text area where you can write, you can check spelling by using built-in spell checker. Just right click over the word marked as red and choose the suggestion.

2. Feed reader is rendering feeds in a more elegant way. Just click on any valid RSS link and see the result.

3. Each tab has its own close button which makes it much more user friendly that the previous one

4. It doesn’t consume memory like FF 1.5 – I though Mozilla debug the memory leak.

It is currently in alpha version and long way to run for the final release – But it’s really awesome and worth testing.

use CURL with HTTP_RANGE header

Hi
Last night I was working with curl extension to see if there is anything so that I can download remote contents with from specific range. For example I want to download a page from offset 0 to 999, that means first 1000 byte. Or a zip file from offset 1000 to 3000, which means 2000 byte starting from 1000 byte offset. If You can do this, you can easily develop remote down loader with resume support.

Finally I have found that there is a option named CURLOPT_RANGE by which you can specify HTTP_RANGE. Lets take a look at the following code which download first 1000 byte from http://www.phpxperts.net/SmartyCheatSheet.pdf file.

<?
$curl = curl_init("http://www.phpxperts.net/SmartyCheatSheet.pdf");
curl_setopt($curl, CURLOPT_RANGE, "0-999");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl);
echo $content;
?>

well, this is the process. I hope many of you will find this useful.

Smarty Book has been published

Smarty PHP Template Programming and Applications My Book, “Smarty PHP Template Programming and Applications” has been published from packt publishers. I co authored this book with Joao Prado, Sr. software enginer from MySQL AB and Lucian Gheorghe, Sr. network engineer for Globtel Internet. It was really fun writing the book first time in my life.

David helped me a lot. But I remember that day when Damian forward my proposal to David. Without Damian, it may not be possible to start with packt. Rushav Sanghavi and Patricia Weir, My technical editors helped a lot to write something that useful. Especially Rushav spends a great amount of time to execute every code snippet.

I just remember a day when I was studying in seventh semester in RUET, where I graduated from, I was thinking if I can write a book internationally, one day…. . It was a dream to me. Thanks a lot to Packt Publishers for their co-operation. Kudos.

Update 15th May, 2006 : Whats the story, morning glory

Long ago i have heard the song when oasis and nirvana were fighting to take position in US top chart. I really like nirvana much more than oasis. “Whats the story, morning glory” was a hit song from oasis which rest in top chart for many weeks. Well, that may suit for todays title.

Yesterday I have analysed wordpress and I found some interesting things. Using wordpress, custom fields for each post and get_post_custom_field() function you can develop almost any kind of website. Its amazing.

I was really surprised to see two themes, one is SemiLogic and another is Kiwi.Both enables some amazing administrative panels in wordpress. Using these themes you can trun yout blog into a full featured CMS. WordPress really rocks!!!

gotokal babur jonyo shopping korlam, khub bhalo lagche ekhon. I really cant believe je ami baba hote jacchi ar kichudin porei. ekta amazing feelings. Ayesha ekhon ektu bhalo tobe sarakkhon tense thak operation niye. Oh Allah, save her from all trouble. operation somvoboto 20 tarikher majhei. Ami preparation nicchi ekta leave neyar jonyo, hoyto 3 soptahoer jonyo.

Last night I worked with CURL, just some RnD. Iwas trying to download files in remote server, where the script is running, with resuming. I know I have to pass HTTP_RANGE header anyhow to manage resumed download. Fortunately in CURL there is a option CURLOPT_RANGE which enables you to fetch any range of bytes if you specify them in “start-end” format. that means if I use curl_setopt($curl_resource, CURLOPT_RANGE, “1000-3000”) it will download 2000 bytes started from 1000 bytes. It was amazing.