Categories
Personal

Good Bye WordPress.com :(

I have been with WordPress.com for a long time. My blog got popularity and it helped me build up many important contacts.

Now I am using self hosted wordpress and no longer need the wordpress.com one. So I deleted both my blogspot and wordpress.com blogs. I won’t miss the blogspot one. But I do miss wordpress.com 🙁

Good bye, WordPress.com 🙁
Wishing you great success in the days ahead !

Categories
PHP

Syntax Highlighting Using PHP

You can publish Syntax Highlighted PHP code easily using php’s built in functions:

  • highlight_string()
  • highlight_file()

 

<?php
highlight_string
(‘<?php phpinfo(); ?>’);
?>

The above code will generate the following HTML codes:

<code><font color=”#000000″>

<font color=”#0000BB”>&lt;?php phpinfo</font><font color=”#007700″>(); </font><font color=”#0000BB”>?&gt;</font>

</font>

</code>

 

As you can guess from the function name, highlight_file() takes a filename/path as a string parameter and returns the code.

 

Many servers are configured to automatically highlight files with a phps extension. For example, example.phps when viewed will show the syntax highlighted source of the file. To enable this, add this line to the httpd.conf:

 

AddType application/x-httpd-php-source .phps

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