21.02.2015, 17:29
Entгo como eu nгo entendo PHP, e nгo conheзo que entenda venho aqui postar esta duvida,
ja que aqui existem varios programadores.
Eu gostaria de saber o que ocorre nestas duas linhas:
E qual a diferenca entre a funзгo a seguir e a parse_ini_file nativa?
Obrigado
ja que aqui existem varios programadores.
Eu gostaria de saber o que ocorre nestas duas linhas:
PHP код:
$sign = !isset($_GET['s']) ? 1 : $_GET['s'];
$nome = !isset($_GET["Nome"]) ? "None" : $_GET['name'];
PHP код:
function parse_ini_file2($f)
{
$newline = "<br>";
$null = "";
$r=$null;
$first_char = "";
$sec=$null;
$comment_chars="/*<;?>";
$num_comments = "0";
$header_section = "";
//Read to end of file with the newlines still attached into $f
$f=@file($f);
// Process all lines from 0 to count($f)
for ($i=0;$i<@count($f);$i++)
{
$newsec=0;
$w=@trim($f[$i]);
$first_char = @substr($w,0,1);
if ($w)
{
if ((!$r) or ($sec))
{
// Look for [] chars round section headings
if ((@substr($w,0,1)=="[") and (@substr($w,-1,1))=="]") {$sec=@substr($w,1,@strlen($w)-2);$newsec=1;}
// Look for comments and number into array
if ((stristr($comment_chars, $first_char) === FALSE)) {} else {$sec=$w;$k="Comment".$num_comments;$num_comments = $num_comments +1;$v=$w;$newsec=1;$r[$k]=$v;}
//
}
if (!$newsec)
{
//
// Look for the = char to allow us to split the section into key and value
$w=@explode("=",$w);$k=@trim($w[0]);unset($w[0]); $v=@trim(@implode("=",$w));
// look for the new lines
if ((@substr($v,0,1)=="\"") and (@substr($v,-1,1)=="\"")) {$v=@substr($v,1,@strlen($v)-2);}
if ($sec) {$r[$sec][$k]=$v;} else {$r[$k]=$v;}
}
}
}
return $r;
}