Hallo,
Ich hab einen Fehler und weiß einfach nicht mehr weiter.
Mein Code:
PHP-Code:
<?php
$usr["web"]="www.page.com";
$usr["name"]="Zomby ";
$usr["fam"]="Killah ";
$out = "new/";
$in = "template/";
$template[]="templ1";
if(isset($usr)){
foreach ($template as $tpl){
$files[]="$tpl.txt"; //Files that needs to be changed (content: %usr:web%)
$files[]="$tpl.htm";
foreach ($files as $file) {
$fhin = fopen("$in$file", "r");
if ($fhin) {
if ($out != "") if (!check_folder($out)) echo "FOLDER $out couldn't be created!\n";
else {
$fhout = fopen("$out$file", "w+");
if ($fhout) {
while (($line = fgets($fhin)) == true) { //Read Next line if possible
$vars = explode("%", $line); //Search for %
$i = 1;
$new_line=""; //No new line
if (count($vars)%2 == 1) { while (isset($vars[$i])) { //If the amount of % can be right
$poss_string = $vars[$i]; //Just check entrys between %
$search = explode(":", $poss_string); //Look if they have a :
// print_r($search);
if (!isset($search[1])) $new_line.=$poss_string;//whoops - error - line shall not change
elseif ($search[0]!="") { //Check if a $search[0] has a value
$name = trim($search[0]); //Remove all additional invesible chars
if ($name == "usr") echo "Name is urs!!\n"; //WTF?!
else echo "$name !== usr\n";
// $name = "usr";
// echo "looking for $name:".$search[1]."\n";
//echo "$usr";
print_r (${$name});
}
$i+=2;
} }else $new_line = $line;
if ($new_line != "") {
fputs($fhout, $new_line);
}
}
fclose($fhout);
} else echo "Signature $tpl file: $file couldn't be created\n";
}
fclose($fhin);
} else echo "Template $tpl file: $file not found\n";
}
}
}
function check_folder($dir){
if ($dir == "") return false;
if (is_dir($dir)) return true;
if (mkdir($dir)) return true;
$dirs = explode("/",$dir);
unset($dirs[count($dirs)-1]);
return check_folder(implode("/",$dirs));
}
?>
Ich will mit templates basteln, für Signaturen die folgender weise aussehen:
Code:
%usr:titel%%usr:name%%usr:fam%
%usr:abt%
%com:name%
%com:namesub%
%com:add1%
%com:add2%
%usr:handy%
%com:tel%
%com:web%
Dachte mir es ist am einfachsten, wenn ich die Werte die ich einsetzen will in Arrays schreibe und die Arrays einfach identifiziere.
Mein Problem:
Wenn "usr" aus dem File gelesen wird scheint es nicht verwendbar zu sein, um es als Variablennamen zu verwenden.
Bei den Code oben überprüfe ich ob "usr" (Aus dem File gelesen) == "usr" ist.
Scheinbar nicht ?!?!?
Was muss ich machen, damit es dass wird?!?
Result:
Zitat:
usr !== usr
PHP Notice: Undefined variable: u in /samba/lamp_log/apache/db/sigs/bug.php on line 32
usr !== usr
PHP Notice: Undefined variable: u in /samba/lamp_log/apache/db/sigs/bug.php on line 32
usr !== usr
PHP Notice: Undefined variable: u in /samba/lamp_log/apache/db/sigs/bug.php on line 32
usr !== usr
PHP Notice: Undefined variable: u in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
usr !== usr
PHP Notice: Undefined variable: u in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
com !== usr
PHP Notice: Undefined variable: c in /samba/lamp_log/apache/db/sigs/bug.php on line 32
|
Hat von euch wer eine Ahnung, was los ist?
Danke für Antwort,
Zomby