up

PHP

PHP normalize function

I post my normalization function. This function find all illegal characters (like: Ő, Ű, ú, í, etc. ) and replace it to latin1 chars. (like: O, U, u, i, etc.) This function works for me on hungarian words. Try it on your text and post your comment about it.

HTML number formatting with PHP

Here is my HTML number formatter. Sometimes the browsers wrap the numbers along thousand separator or decimal pont, but this function prevents this event.

function html_number_format($number, $decimals = 2, $dec_point = '.', $thousands_sep = ',') {
  if ($number === FALSE) {
    return '---';
  }
  return '<span style="white-space: nowrap;">'.number_format($number, $decimals, $dec_point, $thousands_sep).'</span>';
}

PHP GD2 vs Imagick


http://bitprison.net/system/files/gd.jpeg


//include('tmp/Timer.php');

function gd_thumbnail($filename, $width = 200, $height = 200) {
$source = imageCreateFromString(file_get_contents($filename));
$x = imageSX($source);
$y = imageSY($source);

if ($x > $y) { // landscape orientation
$height = intval($y/($x/$width));
} else { // square or portrait orientation
$width = intval($x/($y/$height));
}

$destination = ImageCreateTrueColor($width,$height);

PHP: How to get public properties of object

Sometimes you need all public properties of an object. I've also met this problem. I tried to find some usable native function on php.net, but the only native solution is the ReflectionProperty class. I think It claims too much resource. I've written an own function that has solved this issue.

Let's see the function


/**
* It gets all public properties of given $object.
* @param object $object It must be object.
* @return array that contains all public property name as key and their values. example:

Blog categories:  Web development

Bitprison CAPTCHA System for PHP

I've made a CAPTCHA system what is ease of use for any PHP website. This is a full object oriented class library. Ease of use and ease of customisation. Try it! Feel free to download and use it. Please leave a comment.

Features

  • Very minimal software requirements
  • Ease of customisation (parameters or class extending)
  • Full object oriented library
  • One file one class
Blog categories:  Programming

Easy colour syntax highlighting on webpage

Publish your source code on web with colour syntax highlighting.

For example: How to send correct UTF-8 mail in PHP
This article is contain a PHP code what is syntax highlighted and all PHP function is link to PHP documentation. This code is more understandable, and more readable than simple colourless version.

How to set syntax highlighting on your website?

2 methods of Google-friendly 301 redirection: PHP, Apache .htaccess

Google dont't like indexing a duplicated content. Have you got more domains that point to the same content? Is your site available at www and non-www version of the domain? (example: www.bitprison.net and bitprison.net point to same content) More domain point to my blog: bitprison.com, bitprison.net, bitprison.org and bitprison.hu. I need a solution for avoid duplicated content. I've chosen 301 redirection that google recommends for webmaters in case of duplicated content. It may help Google to determine PageRank for your site more accurately.

Now I'm sharing with you two ways of redirection.

Blog categories:  Programming  Linux