Mistři v programování na #hovnokod

Jak správně zakomentovat obsah.

<?php if (0) { //schovani obsahu ----------------------------------------------------------------- ?>
	<div>Obsah</div>
<?php } //schovani obsahu ----------------------------------------------------------------- ?>

Anonymous,

Else je pro másla! Čísla jsou stringy! Asociační pole jsou technologie budoucnosti!

//----------------------------------------------------------
// 3. definuj mesic
//------------------------------------------
	//$hodnota = cislo mesice
	function mesic($hodnota){	
		if($hodnota == "1"):$vysledek = "leden";endif;
		if($hodnota == "2"):$vysledek = "&uacute;nor";endif;
		if($hodnota == "3"):$vysledek = "b&#345;ezen";endif;
		if($hodnota == "4"):$vysledek = "duben";endif;
		if($hodnota == "5"):$vysledek = "kv&#283;ten";endif;
		if($hodnota == "6"):$vysledek = "&#269;erven";endif;
		if($hodnota == "7"):$vysledek = "&#269;ervenec";endif;
		if($hodnota == "8"):$vysledek = "spen";endif;
		if($hodnota == "9"):$vysledek = "z&aacute;&#345;&iacute;";endif;
		if($hodnota == "10"):$vysledek = "&#345;&iacute;jen";endif;
		if($hodnota == "11"):$vysledek = "listopad";endif;
		if($hodnota == "12"):$vysledek = "prosinec";endif;
		//return		
		return($vysledek);//vratime vysledny pocet surovin
	}
//END

Anonymous,

a toto je prosim ing...

public function vytvorKontrolniSoucet($data)
{
        $cislo = rand(1, 1000);
        return md5($data['datum_svozu'] . $cislo . $data['barcode']);
}

Anonymous,

Abstraktni metoda jako final?

abstract class Foo
{
    final function getName() {
        switch (get_class($this)) {
            // Zde musí být case pro všechny potomky
            case 'FooFoo': return 'foo foo';
            case 'FooBar': return 'foo bar';
            default: throw new InvalidStateException;
        }
    }
}

class FooFoo extends Foo {}

class FooBar extends Foo {}

Anonymous,

v kódu administrace jednoho nejmenovaného e-shopu

    /**
     * Využito v - Tel.. Objednavky
     * Nova telefonicka objednavka
  @Autor: Lukáš

  NEŠAHAT - MOŽNÁ TO SPADNE KDYŽ SE V TOM NĚKDO ZAČNE HRABAT KROMNĚ MNĚ :D
     */
    public static function telObjednavka() {
    	$konec = true;
    	$suma = 0;
    	$b = 0;
    	$i = 0;
    	$sqlDrinks = "SELECT * FROM " . TABLE_DRINKS . " WHERE PK_idd=:idd";
    	$sqlItem = "INSERT INTO " . TABLE_ITEMS . " SET FK_ido=:FK_ido, FK_idd=:FK_idd, pc=:pc, price=:price";

    	$lastusers = DB::assoc(DB::query("SELECT * FROM " . TABLE_CUSTOMERS . " WHERE prettyname=:name ", array(":name" => $_POST['name'])));

			// zalozeni noveho uzivatele
    	if (empty($lastusers)) {
    		$array = array(":name" => $_POST['name'], ":address" => $_POST['address'], ":number" => $_POST['number'], ":town" => $_POST['town'], ":zipcode" => $_POST['zipcode'], ":mobile" => $_POST['telefon'], ":mail" => $_POST['email']);
    		DB::query("INSERT INTO " . TABLE_CUSTOMERS . " SET prettyname=:name, address=:address, number=:number, city=:town, zipcode=:zipcode, mobile=:mobile, mail=:mail", $array);
            $lastusers = DB::assoc(DB::query("SELECT * FROM " . TABLE_CUSTOMERS . " WHERE prettyname='". $_POST['name'] . "'"));
    	}

    	$lastOrders = DB::assoc(DB::query("SELECT MAX(PK_ido) FROM " . TABLE_ORDERS));
    	$order = $lastOrders['MAX(PK_ido)'] + 1;

    	while ($konec) {
    		if (isset($_POST['zbozi' . $i])) {
                $item = $_POST['id_napoje_' . $i];
    			$Drinks = DB::assoc(DB::query($sqlDrinks, array(":idd" => $item)));
    			$celkem = $_POST['kusu' . $i] * $Drinks['price'];
    			$arrayItem = array(":FK_ido" => $order, ":FK_idd" => $Drinks['PK_idd'], ":pc" => $_POST['kusu' . $i], ":price" => $celkem);

    			DB::query("UPDATE " . TABLE_DRINKS . " SET pc_stock=:pc, blocked=:block WHERE PK_idd=:idd",
    				array(":idd" => $Drinks['PK_idd'], ":pc" =>  $Drinks['pc_stock'] - $_POST['kusu' . $i], ":block" => $Drinks['blocked'] + $_POST['kusu' . $i]  ));

    			DB::query($sqlItem, $arrayItem);
    			$suma = $suma + ($_POST['kusu' . $i] * $Drinks['price']);
    		} else {
    			if ($b == 10) {
    				$order = array(":FK_idcu" => $lastusers['PK_idcu'], ":PK_ido" => $order, ":FK_ids" => "1", ":closed" => "0000-00-00 00:00:00", ":created" => date("Y-m-d H:i:s"), ":suma" => $suma);
    				DB::query("INSERT INTO ". TABLE_ORDERS . " SET PK_ido = :PK_ido, FK_idcu= :FK_idcu, FK_ids = :FK_ids, created=:created,closed=:closed, price_sum=:suma, done='0'", $order);
    				$konec = false;
    			} else {
    				$b = $b + 1;
    			}
    		}
    		$i = $i + 1;
    	}
    }

Anonymous,