PHP code highlight
This script will highlight string inside [code] and [/code] only.
< ?php
// function to call
function highlight_code($txt){
$hasil = preg_replace_callback('{\[code\]((.|\n)+?)\[/code\]}i',"replace_code", $txt);
return $hasil;
}
// main function
function replace_code($ketemu){
$hasil = trim($ketemu[1], "\n ");
return highlight_string($hasil, true);
}
// sample of usage:
$string = "It's PHP info: [ code ] [ /code ]";
echo highlight_code($string);
?>
The main function is the replace_code()
function that will highlight the string. But we need to return the the highlighted string back into the full strings. So we use the callback, using highlight_code() function.
Good luck ^_^
Re-claim this blog on technorati
This is just a reclaiming this blog on Technorati Profile. Please ignore.
What Opera Dragonfly could be
Opera Watch reported that they’re preparing something called Opera Dragonfly. There’s no clue what the dragonfly could be but a teaser said:
“I won’t say quite yet, but I do think that, in my opinion, it is the most important project we have on going at the moment, and probably since I’ve been at the company. It won’t directly affect everybody, but will hopefully become invaluable for those that it does.”
So I’m thinking that the dragonfly will be a developer tools to dealing with HTML/CSS/Javascript just like firebug in Firefox.
It’s great if the dragonfly is realy a developer tools, since the current developer tools available for Opera is not very handy and rather dificult to use. Let’s wait for the dragonfly.
Get DPI value of an image using PHP
This is a simple function I wrote to get a DPI (dot per inch) value from an image using PHP only, without the need of ImageMagick nor GD library. The script was inspired from denisb post (the third post). At the forum, he described how to get the DPI value stored within the file.
< ?php
function get_dpi($filename){
// open the file and read first 20 bytes.
$a = fopen($filename,'r');
$string = fread($a,20);
fclose($a);
// get the value of byte 14th up to 18th
$data = bin2hex(substr($string,14,4));
$x = substr($data,0,4);
$y = substr($data,4,4);
return array(hexdec($x),hexdec($y));
}
// output the result:
print_r(get_dpi2('filename.jpg'));
?>
I have tried this function to get DPI value of an image that I generated using Photoshop and worked as expected but failed to get DPI value from an image from any digital camera. It returned weird value instead.
Any idea why this function failed to retrieve DPI value from image that generated by digital camera? Please share your opinion.
Opera Mobile jumps from 8.6 to 9.5

You might questioning what happen with Opera Mobile version 9 and why Opera Mobile jumps its version from 8.65 to 9.5.
Opera Mobile is intended to be a replacement for Opera Desktop in a mobile device. To achieve the same browsing experience between desktop and mobile, both browsers must have the same method to display the website. Since the latest version of Opera Desktop is 9.5 so Opera Mobile should have the same version and same rendering engine. Opera Mobile 9.5 using the same rendering engine as Opera Desktop 9.5 called Presto.
By this way, Opera hopes that there’s no difference between browsing using PC or mobile gadgets. Opera also said that this version is a lot faster than previous and the GUI was completely rebuild to increase user experience. And hey, it runs widgets just like Opera for desktop!
Now I’m waiting for Opera Mobile 9.5 to be available for Symbian UIQ 3.


