1
0

fichiers de test + correctifs

correctifs de styles (polices)
This commit is contained in:
Jérémie Ducastel
2015-08-10 00:17:48 +02:00
parent 4393c5be63
commit ca6f0446f0
12 changed files with 404 additions and 4 deletions

44
tests/php.php Normal file
View File

@ -0,0 +1,44 @@
<?php
function parseHttpAcceptLanguage($str=NULL) {
// getting http instruction if not provided
$str=$str?$str:$_SERVER['HTTP_ACCEPT_LANGUAGE'];
// exploding accepted languages
$langs=explode(',',$str);
// creating output list
$accepted=array();
foreach ($langs as $lang) {
// parsing language preference instructions
// 2_digit_code[-longer_code][;q=coefficient]
ereg('([a-z]{1,2})(-([a-z0-9]+))?(;q=([0-9\.]+))?',$lang,$found);
// 2 digit lang code
$code=$found[1];
// lang code complement
$morecode=$found[3];
// full lang code
$fullcode=$morecode?$code.'-'.$morecode:$code;
// coefficient
$coef=sprintf('%3.1f',$found[5]?$found[5]:'1');
// for sorting by coefficient
$key=$coef.'-'.$code;
// adding
$accepted[$key]=array('code'=>$code,'coef'=>$coef,'morecode'=>$morecode,'fullcode'=>$fullcode);
}
// sorting the list by coefficient desc
krsort($accepted);
return $accepted;
}
class SomeClass {
public function __init() {
# do something
throw new Exception('pipo');
}
public static function pipo($var) {
return $var + 12;
}
}
SomeClass::pipo(12);
?>