-1

generirajSkripte() is my function, but its not important for detecting problem. So, next code work good:

generirajSkripte('pages/','developingStyles/','develop'); 
generirajSkripte('pages/','developingStyles/fonts/','fonts');  

This code work good too:

//All these variable matching strings above!
generirajSkripte('pages/',$Pages[0].'/',$ScriptNames[0]); 
generirajSkripte('pages/',$Pages[0].'/fonts/',$ScriptNames[1]);  

And this code doesnt work:

generirajSkripte('pages/',$Pages[0].'/',$ScriptNames[0]); 
generirajSkripte('pages/',$Pages[0].'/'.$Pages[1].'/',$ScriptNames[1]);  

Variable $Pages[1]=='fonts' 101% , I have spent 8 hours for check it and much more...no anything is no-sense!

So, lets inside generirajSkripte():

function generirajSkripte($pageFolderName,$path,$scriptName)
    {
    if(!file_exists(noSlashRight($pageFolderName.$path))) 
        {
        echo '(test echo) dont exist: '.$pageFolderName.$path;br();
        //die('miki');
        if (!mkdir(noSlashRight($pageFolderName.$path), 0777, true)) {die('Failed to create folders...');};

        //model.php
        $file=fopen($pageFolderName.$path.$scriptName."_m.php", "w");  
        fwrite($file, "<?php nnnnn?>"); fclose($file);

        //wiev php (content)
        $file=fopen($pageFolderName.$path.$scriptName."_w.php", "w"); 
        $fileTxt=""; 
        fwrite($file, $fileTxt );
        fclose($file);

        //file.js
        $file=fopen($pageFolderName.$path.$scriptName.".js", "w");
        fwrite($file, "/*\n onload(function()\n\t{\n\t});\n*/"); 
        fclose($file);

        //file.css
        $file=fopen($pageFolderName.$path.$scriptName.".css", "w");
        fclose($file);


        echo 'There is new script for path: '.$pageFolderName.$path;br();
        }
    }

In situation when code doesn't work, there is generate a bunch of strange folders, but test echo line is not triggered. So wierd!!

Error? There is not error, only I get extra no-sense and unexpected hierarchy of folders. The names of these folders are getting like all around my main folder. Some names of folders are like my images in my img folder which is on top level of structure.

When I did print variables...what I got in function generirajSkripte(), all variables was exactly like expected...and same in both case!

I was looking for some extra characters in $Pages, so I did test:

echo '<pre>';
print_r($Pages);
print_r($ScriptNames);
echo '</pre>';

and got:

Array 
( 
    [0] => developingStyles 
    [1] => fonts 
    [2] =>  
    [3] =>  
    [4] =>  
) 
Array 
( 
    [0] => develop 
    [1] => fonts 
    [2] =>  
    [3] =>  
    [4] =>  
)  

..emtpy position are expected too!

And, one more thing. When I getting unexpected behavior....I run code while my target file is exist! So main condition should be false ...and there is supposed nothing to happen. But, I get all new folder structere with strange names...and cant trigger anything else in same block of code, like my echo test funcion in first line of this block.

1 Answers1

0

This was definitly the most confused bug I have ever seen. After 10+ hours of debuging, i found that PHP was confused with HTML script which is included in proceeding code. Not necessarily plain HTML, also if I used echo function for generate some HTML parts, it has cause the same confusion.

This part of code was the key:

echo "
<div id='userBox' class='valign_inline'>
    <div id='avatar_and_name_box' class='valign_inline'>
        <div id='avatarBox' class='krug24 p'><img src='img/profile-photo.png'/></div>
    </div>
</div>";

So, lets focus the img tag. If I change this tag name, there is no bug any more! If I changes src attribute of this tag, it will directly causes diferent name of unexpected folders (while generating folders)

This is obviously unexpected behavior of PHP? ...I dont know what would be my mistake? :/