Frist off it has been a long time, I know but I have started up a new project (now that I am out of school for summer) and have already hit a brick wall. It's nie to be back.
Okay, so here is what I am attempting to do. I would like to create a php framework to make things such as blogs and forums easier to set up and customize after creation. While there may already be something like tis out there I haven't been able to find it and, as you mayremember about me (wierd as I am) I prefer to write my own code so that I can edit it later with less hassle.
Basically what I am attempting to succeed in for a final project is to have some code in standard (X)HTML like so:
CODE
<html>
<head>
<import[[standard_skin.css,js_files.js]] />
</head>
<body>
<table>
<tr>
<td style="width: 150px"><!-- Left pane-->
<user>
<avatar[[float:left]] />
<username />
Posts: <posts />
etc.
</td>
<td>
content here
</td>
</tr>
</table>
</body>
</html>
and have php able to successfully parse the additional (at this point made up) (X)HTML tags; so the <username> tag would post the user's username and so on.
The problem I am having at this point in time, and yes it is very early into the whole project; no this isn't for school or anything other than my personal quest for knowledge.
So, it is about time I show some work (all I am asking at this point is for some help getting this to work properly).
Here are my files, with the exact contents:
index.php:
CODE
<?php
require'class.php';
require'tmp.php';
$compile_fw = &new framework;
echo $compile_fw->init($t_str);
?>
class.php:
CODE
<?php
class time{
function tostamp($time){
return strtotime(Stime);
}
}
class framework{
function init($str){
$from = "|\<(.*?)\[\[(.*?)\((.*?)\)\]\]\/>|i";
$to = '$tmp = &new $1; $tmp->$2($3);';
$content = preg_replace($from, $to, $str);
return $content . '<br>OP: ' . eval($content);
}
}
?>
tmp.php:
CODE
<?php
$t_str = <<<EOS
<time[[tostamp('now')]]/>
EOS;
?>
NOTE - in this case tmp is standing for template, not temporary.
Okay, as you can see I have the class and tmp files required by the index file, then go throught and have it "compile" the tmp file and return an output, which looks like so:
CODE
$tmp = &new time; $tmp->tostamp('now');
OP:
Where the OP: is should be giving a timestamp but at this point is not outputting anything (and is getting quite annoying).
As I haven't had much use for eval() in the past it is possible (and very probable) that I am mis-using it and thus my problems are occurring, however I believe that there is something else adding to the issues I am having.
Ideally the eval() statement would be unnecessary but at this time I see no way around using it.
Hopefully someone can point me in the right direction.
Thanks in advance,
BetaWar
PS - if you are itnerested in seeing the current version in all its broken glory here is the address:
http://www.reigninggames.com/tests/app_tests/phpfw/index.php