WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

Antwort
 
Themen-Optionen Ansicht
Alt 17.05.2011, 21:00   #1
ZombyKillah
Trashtroll
 
Benutzerbild von ZombyKillah
 
Registriert seit: 19.10.2008
Ort: far away but still in austria
Beiträge: 1.194

Mein Computer

Standard PHP - Problem

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)%== 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
____________________________________
It's more fun to write crap that nothing!
Just kidding.

Ich bin für kreative Rechtschreibung, da kann man keine Fehler machen
ZombyKillah ist offline   Mit Zitat antworten
Alt 17.05.2011, 21:27   #2
ZombyKillah
Trashtroll
 
Benutzerbild von ZombyKillah
 
Registriert seit: 19.10.2008
Ort: far away but still in austria
Beiträge: 1.194

Mein Computer

Standard

Hab herausgefunden was ich machen muss:
PHP-Code:
$name trim($search[0]);
$name str_ireplace("\0","",$name); 
Scheinbar werden da ein paar Zeichen zwischen den Buchstaben noch ausgeblendet.
____________________________________
It's more fun to write crap that nothing!
Just kidding.

Ich bin für kreative Rechtschreibung, da kann man keine Fehler machen
ZombyKillah ist offline   Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 20:33 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag