ZamCamp #6 - Najczęstsze błędy w PHP

  • Upload
    zamcamp

  • View
    1.235

  • Download
    2

Embed Size (px)

Citation preview

Czyli od Hello World do ZCE...

Przemysaw eRIZ PawliczukZend Certified Engineer

Bdy skadni

echo 'hello world'

Brak wci w kodzie

if($cond){while(1){for($a=0;$a

jo

Porwnywanie float

echo M_PI; //3.1415926535898var_dump(M_PI==3.1415926535898); //false

Wynajdywanie koa na nowo

function pad_zeros($number, $zeros) { if (strpos($number, '.') !== false) { preg_match('#\.(\d+)$#', $number, $match); $number .= str_repeat('0', $zeros-strlen($match[1])); return $number; } else { return $number.'.'.str_repeat('0', $zeros); } }

// ...

// english notation without thousands seperator $english_format_number = number_format($number, 2, '.', '');

Bd #1

Warning: Cannot modify header information - headers already sent by

Bd #2

Type: [2048] date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead, line 154 of file /usr/local/apache/www/htdocs/artel-elektro.pl/classes/vMain.php

RTFM!

Bdy w rozumowaniu skadni zmiennych

echo HelloWorld;echo 'HelloWorld';

echo "$zmienna";

echo ''.$s_User.''

Brak filtrowania danych

require 'strony/'.$_GET['strona'];

Mylenie generowanego kodu ze rdem skryptu

require 'http://example.com/script.php';

Kadorazowe zliczanie elementw w ptli

$str = 'Kot ma Al';

for($a=0;$a