Categories
PHP

Lambda Function in php

Lambda function became very popular in Python. And from version 4.0.1, we have it on php as well.

Here’s a little snippet for your copy-paste comfort :

<?php
$newfunc 
create_function(‘$a,$b’‘return “ln($a) + ln($b) = ” . log($a * $b);’);
echo 
“Lambda Function: $newfunc\n”;
echo 
$newfunc(2M_E) . “\n”;?>

 

Give it a try on php-cli to check out J

Categories
PHP

php-gtk sample app

In my previous posts I wrote about php-gtk. Just a quick reminder: php-gtk lets you build desktop GUI applications for the GTK platform. These applications can be deployed on multiple platform without any hassle.

Here’s the source codes of a very simple “Hello, World!” application in php-gtk:

 

<?php

if (!class_exists(‘gtk’)) {

die(“Please load the php-gtk2 module in your php.inirn”);

}

 

$wnd = new GtkWindow();

$wnd->set_title(‘Hello world’);

$wnd->connect_simple(‘destroy’, array(‘gtk’, ‘main_quit’));

 

$lblHello = new GtkLabel(“Just wanted to sayrn’Hello world!'”);

$wnd->add($lblHello);

 

$wnd->show_all();

Gtk::main();

?>

 

If you go through the codes, you will get the structure very easily.

  • if (!class_exists(‘gtk’)) { die(“Please load the php-gtk2 module in your php.inirn”);}
    This line just checks if php-gtk is installed.
  • $wnd = new GtkWindow();
    Creates a new window.
  • $wnd->set_title(‘Hello world’);
    Sets the window title.
  • $wnd->connect_simple(‘destroy’, array(‘gtk’, ‘main_quit’));
    A bit complex. Connects the main_quit method of gtk with the “destroy” event of the window.
  • $lblHello = new GtkLabel(“Just wanted to sayrn’Hello world!'”);
    Creates a new label with the predefined text.
  • $wnd->add($lblHello);
    Adds the label to the main window.
  • $wnd->show_all();
    Shows all components.
  • Gtk::main();
    Starts the main loop. The application runs.

 

That was easy, wasn’t it?

Categories
Personal

Orientation Class: BBA, Khulna University

The day before, we were told that the BA discipline of Khulna University has a very “distinguished status” and there will be an exceptional orientation class staged for the new comers. I could easily imagine that it was going to be a dazzling show down that would match the shining image of the discipline without any concession.

I woke up late, at around 8 AM in the morning, had my breakfast on a hast and went out for the University. My dad picked me up on his bike halfway through the journey. When we reached the auditorium in the 2nd Academic Building, my dad was welcomed inside and I was requested to wait outside provided that they had special arrangements for us. After a while we were welcomed inside. We were welcomed with a bunch of flowers by two charming senior female students of the discipline. We took seats and the multimedia projector had a music video running on it. The video was shot probably by the senior students and it gave us some snap shots of the university life of the already BBA students at KU. It was a nice show with some great shots from the ever exciting university life along with soft rock music. We waited listening to some country music until our guests arrived. The guests took seats and the real show was unfolded. We had recitation from the holy Quran, speech from the teachers, guests and students. There was another great video which was definitely a great show off. The video has inspired me a lot. We took oath and then we were let out and asked to gather inside a room in the 1st Academic Building. We were served refreshment there.

In short that was the orientation. But the program was of about 2 hours. I feel sorry that I cannot give you every bit of details on it. The university life is gripping me with a great pressure and demanding me to spend more time for my academic courses.

After the ceremony, I completed some other procedures which were left unfinished the previous day. Then I got back home. I did enjoy today. It was a great fun and I am proud to be a grad student at KU’s BBA program.

University was extremely fun, and I’m going to miss it a lot especially the mini projector which we used to use as it was portable, we used to adjust it to our comfort and watch the ppt’s the way we wanted. You can check out these best cheap projector under 100 if you are having a hard time buying a much expensive model. One thing which still amazes me till today was that despite it being a mini projector, it still managed to showcase clear quality.

Anyways I’m finally a grad student. Now its time to accomplish other things in life.