Derniers snippets latest snippets

Singleton en PHP5

Instance unique d'un objet.

<?php 
class Singleton 
{ 
    private static $_instance ; 
 
    private function __construct() { }
 
    public static function GetInstance() 
    { 
        if (!isset(self::$_instance)) 
        { 
            self::$_instance = new Singleton() ; 
        } 
        return self::$_instance; 
    }
}
?>
by Nicolas Perriault on 2006-10-11, tagged design  pattern  php  singleton 

Obtenir un tableau de caractères depuis une chaîne en PHP4

En php5 on a str_split : http://fr.php.net/manual/fr/function.str-split.php

Et en PHP4 :

$chars = preg_split('#(?<=.)(?=.)#s', $string);
by Nicolas Perriault on 2006-10-11, tagged array  php  string 
(3 comments)

Hello World !

Hi all, this is just a test :

<?php
abstract class HelloWorld {
  static public function sayIt()
  {
    echo 'Hello World !';
  }
}
 
HelloWorld::sayIt();
?>
by Nicolas Perriault on 2006-10-09, tagged php  test